Hi
I need to extract text between two dynamic strings. Eg : User XYZ updated : This has been tested .
User ABC edited: yet to test.
I need to extract value between ’ user XYZ Updated: and User ABC edited: ’ . XYZ and ABC are subject to change.
Hi
I need to extract text between two dynamic strings. Eg : User XYZ updated : This has been tested .
User ABC edited: yet to test.
I need to extract value between ’ user XYZ Updated: and User ABC edited: ’ . XYZ and ABC are subject to change.
Hi @Rilna_Rilna
This is achievable with Regex.
Here is the Regex Pattern option #1:
.NET Regex Tester - Regex Storm.
Regex Pattern Option #2:
.NET Regex Tester - Regex Storm.
To apply this in UiPath try this with an Assign activity.
Left Assign:
YourStringResultVar
Right Assign:
System.text.regularexpressions.Regex.Match(yourStringVar, InsertRegexPattern).ToString
Take a look at my Regex MegaPost:
Cheers
Steve
Hi @Rilna_Rilna
Please use this in assign
strout = System.text.Regularexpressions.regex.match(str,"(?<=User\s\w{3}\supdated)(\s|.)*(?=User\s\w{3}\sedited)").Value
Str - this is where your input string is stored
Strout - this is where your output string is stored
Cheers
Please note ABC or XYZ can be any number of words and also the words to extract can span in multiple lines. How to handle
Hi
You will need to update the Text anchors so it can handle.
Got some samples handy?
Take a look at this pattern.
Cheers
Steve
Then try this
strout = System.text.Regularexpressions.regex.match(str,"(?<=User\s\w{1,}\supdated)(\s|.)*(?=User\s\w{1,}\sedited)").Value
Cheers
@Rilna_Rilna
find for a first start a pattern, which incorporates some flexibility like: multiline spannings, different positions of the : , Case insentive check…
strPattern: (?<=user[\s\S]+?updated\s*?\:?)[\s\S]*?(?=user[\s\S]+?edited)
myString =
System.Text.RegularExpressions.Regex.Match(strText, strPattern, RegexOptions.IgnoreCase).Value