Dynamic String Manipulation - Required help

Hello Team,

I have a string like below

O/D interest (Approval required >=Swe200) (SW12300)

I want to split and fetch the code that is available in the last brackets.

The problem is that SW code will available in the middle of start anywhere in the string. And also along with SW code if in future we get like below expression bot will able to extract all the codes without any fail…

O/D interest (Approval required >=Swe200) (SW12300) (RE20092)

Kindly help me with the dynamic expression which will work for all types. It’s kindl of urgent.
Thanks in advance.

Regards,
Sweety

Hi @Swetha_V ,

For the Highlighted expression do we need to fetch the RE code as well ?

Hi,

It will be like some times will get SW code and alone in the string. And sometimes will get both. So I need single expression which can work for both.

Thanks.

Hi @Swetha_V

You can use the following RegEx in that case:

((SW\w+))

image

Hope this helps,
Best Reards.

Hi @Swetha_V ,

Maybe the below Regex Expression is what you require :

(?<=\()SW.*?(?=\))

Expression :

Regex.Match(strInput,"(?<=\()SW.*?(?=\))").Value

image

If you need to get all the codes (not just SW ones), you can use the below expression:
((\w+))

Thanks, it’s working for get the single code from the string which is available anywhere in the string. Now I am trying to get both codes…

Hi,

I tried but I am getting only single code.

Thanks

@Swetha_V

Can you elaborate on this point please? A sample string with expected output might help us analyze your requirement.

Best Regards.

Hi,

As I mentioned two codes in single string. This kind of string will get sometimes, in that case I need both SW code as well as RE code.

There should be single expression, and it should get single code as well as multiple code from the string based on the input.

O/D interest (Approval required >=Swe200) (SW12300)

O/D interest (Approval required >=Swe200) (SW12300) (RE20092)

Thanks…

@Swetha_V

So from the above string, you only want ‘SW12300’, even if there are multiple SW data or any other data like RE, you want the first occurrence of SW data, is it right?

Best Regards.

@Swetha_V

Can you please try this

\([A-Z]{2}\d{5}\)

cheers

No, I want to split and store both SW and RE code into variable. Thanks

Hi @Swetha_V

Hope this xaml file would be of help to you.

Use Matches activity,
Loop through all the matches, check if it contains RE, store it in a variable you, check if it contains SW store it in another variable.
image
Regex.xaml (6.4 KB)

Thanks,
Aditya