Jump to content

Recommended Posts

Posted

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<-
Posted

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
Posted

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

-SET &VARIABLE = 'Customer_13426, ctdacustom_6544, customer_xz_456_hguyrd'; -SET &PATTERN = PATTERNS(&VARIABLE);-SET &PATTERN = REPLACE(&PATTERN, 'A','$');-SET &PATTERN = REPLACE(&PATTERN, 'a','$');-SET &PATTERN = REPLACE(&PATTERN, '_','$');-SET &PATTERN = REPLACE(&PATTERN, ' ','9');-SET &PATTERN = REPLACE(&PATTERN, ',','9');-SET &VARIABLE = EDIT(&VARIABLE, &PATTERN); -? &VAR

Output looks like this:

image.png.d39aa727393d67ea5d9aaa8e41360350.png 

Posted

You don't say what release you are on so the PATTERNS function may not be available to you. There is the older PATTERN function which you could use.

If you are on a later release, I found something even better.

-SET &VARIABLE = REGEXP_REPLACE(&VARIABLE, '[^0-9, ]', '');

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...