Swetha_V
(Swetha V)
May 15, 2023, 6:29am
1
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 ?
Swetha_V
(Swetha V)
May 15, 2023, 6:34am
4
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+))
Hope this helps,
Best Reards.
Hi @Swetha_V ,
Maybe the below Regex Expression is what you require :
(?<=\()SW.*?(?=\))
Expression :
Regex.Match(strInput,"(?<=\()SW.*?(?=\))").Value
Anas-p-v
(Anas Pv)
May 15, 2023, 6:55am
7
If you need to get all the codes (not just SW ones), you can use the below expression:
((\w+))
Swetha_V
(Swetha V)
May 15, 2023, 7:06am
8
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…
Swetha_V
(Swetha V)
May 15, 2023, 7:06am
9
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.
Swetha_V
(Swetha V)
May 15, 2023, 7:24am
11
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
(Swetha V)
May 15, 2023, 7:36am
14
No, I want to split and store both SW and RE code into variable. Thanks
adiijaiin
(Aditya Jain)
May 15, 2023, 7:39am
15
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.
Regex.xaml (6.4 KB)
Thanks,
Aditya