Jump to content
The ibi Community has moved to a new platform: Please Sign In and choose Forgot Password to continue

Extracting Integer value from a string

Abraham Sunil Mutyala 3

Recommended Posts

Not the most efficient but as a quick answer

-SET &VARIABLE = 'customer_13426, ctdacustom_6544, customer_xz_456_hguyrd';-SET &NUM1 = REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(UPPER(&VARIABLE),'A',''),'B',''),'C',''),'D',''),'E',''),'F',''),'G',''),'H',''),'I',''),'J',''),'K',''),'L',''),'M',''),'N',''),'O',''),'P',''),'Q',''),'R',''),'S',''),'T',''),'U',''),'V',''),'W',''),'X',''),'Y',''),'Z','');-SET &NUM2 = REPLACE(REPLACE(REPLACE(REPLACE(&NUM1,'_',''),'-',''),'.',''),'?','');-TYPE >-&NUM2<-
Link to comment
Share on other sites

Little more advanced

-SET &STRG = 'customer_13426, ctdacustom_6544, customer_xz_456_hguyrd';-SET &ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';-SET &SPEC = '!@#$%^&*()-_=+/{}"<>?|~.';-*-*To remove the spaces at the same time-*-* But STRIP may also be used to remove spaces-*-*-SET &SPEC = '!@#$%^&*()-_=+/{}"<>?|~. '; -REPEAT STRIPALPHA FOR &I FROM 1 TO 26-SET &TOKEN = SUBSTRING(&ALPHA, &I, 1);-SET &REPL = REPLACE(UPPER(&STRG), '&TOKEN.EVAL', '');-SET &STRG = &REPL;-STRIPALPHA-*-* To remove the spaces at the same time, loop 26 time with &SPEC including the space character.-*-* But STRIP may also be used to remove spaces-*-*-REPEAT STRIPSPEC FOR &I FROM 1 TO 26-REPEAT STRIPSPEC FOR &I FROM 1 TO 25-SET &TOKEN = SUBSTRING(&SPEC, &I, 1);-SET &REPL = REPLACE(&STRG, '&TOKEN.EVAL', '');-SET &STRG = &REPL;-STRIPSPEC-TYPE NEW STRING: &STRG
Link to comment
Share on other sites

The PATTERNS function seems tailor-made for something like this:


Output looks like this:


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...