Page 1 of 1

Any String function to split the string into two substrings

Posted: Thu Aug 11, 2005 3:25 am
by balaid
Forum,

I have a String like 'ABC111'. i need to spilt into two strings based on numeric and non numeric chars. Is there any function useful for this.


Can any one help me.

Posted: Thu Aug 11, 2005 3:44 am
by ArndW
The good news is that there are quite a few functions available for you to use, ranging from ALPHA, FMT through ICONV/OCONV and substring.

The method you choose really depends on what you want to do. If your string always has the format {n-characters}{n-integers} then you can do something more efficient than if they were mixed.

Code: Select all

TextString = CONVERT('0123456789','',InString)
Will remove all numbers from the string. If your data allows it, then

Code: Select all

NumbersString = InString[LEN(TextString)+1,9999]
will give you the numeric portion. I like to use the FMT function but don't have the codes available to show you (no BASIC manual on this PC)

Posted: Thu Aug 11, 2005 7:30 am
by pnchowdary
Hi Balaid,

Like Arndw rightly pointed out, there are a lot of ways you can achieve your goal.

Here is one using Oconv

For Extracting Numbers

Code: Select all

X = Oconv(IN.INPUTSTRING,"MCN")
For Extracting Characters

Code: Select all

X = Oconv(IN.INPUTSTRING,"MCA")