Hi Everyone, I am new to string operations and I need to fetch the string between the second slash ‘/’ and next space in below string. In this case, the string to be fetched is KSHARMA.
Job 243955/X115949A1 /KSHARMA is locking account 41 38142
One of the way of achieving it is doing splitstring with ‘/’ as delimiter and getting text ‘KSHARMA is locking account 41 38142’ from third array element. Then again doing splitstring on this third array element with space ’ ’ as delimiter and getting KSHARMA in first array element.
However this would be long process and I am sure there can be better way of achieving this, probably in one shot. Any help on it would be greatly appreciated. Thanks!
Use Matches activity
1.1 The input should be the string.
1.2 Pattern should be “(?<=/)(.*?)(?=\ )”
1.3 Result is of type string. (let’s say arrMatches as variable name)
It matches two strings. So you will use arrMatches(1).ToString to get KSHARMA
I am getting below error while launching code probably due to lower version of uipath. Can you please let me know the exact regex expression you are using.
Buddy @Kapil
Here you can go for split method itself with a single shot buddy
in_text = “Job 243955/X115949A1 /KSHARMA is locking account 41 38142”
then out_text = split(split(in_text,“/”)(2).ToString," ")(0).ToString
this would give you the KSHARMA value in a single step buddy
or
try this buddy with regexp “(?<= \/)(.*?)(?=\ )”
in matches regularexp and pass the string you want buddy, get the output with variable out_text
and get them directly like this buddy out_text.tostring buddy @Kapil in one shot as you expect buddy
I did lookup for this package in uipath forum and as per them, we cant install this package but can add it to imports. I did same however faced same error.
However I got solution to my problem using Split option. Thanks for your help!