Any String function to split the string into two substrings

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
balaid
Participant
Posts: 7
Joined: Sun Aug 07, 2005 11:51 pm

Any String function to split the string into two substrings

Post 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.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post 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)
pnchowdary
Participant
Posts: 232
Joined: Sat May 07, 2005 2:49 pm
Location: USA

Post 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")
Thanks,
Naveen
Post Reply