Hi UiPath,
let say I have 2 possibles strings below:
10-77349_PLS LOAD & GIVE ME PO#_APR&RETAILS. THANK YOU
or
10-77349_PLEASE LOAD & GIVE ME PO#_APR&RETAILS. THANK YOU
How can I manipulate it to have the output format below:
10-77349_APR&RETAILS
Hi UiPath,
let say I have 2 possibles strings below:
10-77349_PLS LOAD & GIVE ME PO#_APR&RETAILS. THANK YOU
or
10-77349_PLEASE LOAD & GIVE ME PO#_APR&RETAILS. THANK YOU
How can I manipulate it to have the output format below:
10-77349_APR&RETAILS
outputString. Here’s an example of the assignment:scssCopy code
outputString = System.Text.RegularExpressions.Regex.Match(inputString, "(\d{2}-\d{5})_.*?_([A-Z]{3}&[A-Z]{7})").Groups(1).Value + "_" + System.Text.RegularExpressions.Regex.Match(inputString, "(\d{2}-\d{5})_.*?_([A-Z]{3}&[A-Z]{7})").Groups(2).Value
In this example, the regular expression pattern (\d{2}-\d{5})_.*?_([A-Z]{3}&[A-Z]{7}) is used to match and capture the desired parts of the input string. The first captured group (Groups(1)) represents the “10-77349” part, and the second captured group (Groups(2)) represents the “APR&RETAILS” part. The + operator is used to concatenate the captured groups with the “_” separator.
After executing this Assign activity, the outputString variable will contain the desired formatted output: “10-77349_APR&RETAILS”.
Hi,
Can you try the following expression?
System.Text.RegularExpressions.Regex.Replace(yourString,"(^[-\d]+).*?PO#_([^.]+).*","$1_$2")
Regards,
Hi
thanks for everyone’s effort in answering my question.
Let say I just want to extract the last one below?
APR&RETAILS is dynamic string
Hope to hear from you guys soon
Hi @alvin.c.apostol26
Try using the below Regex expression:
((?<=#_)[\w&]+)
Hope it helps!!
Regards,
Hi,
My first expression will work because it doesn’t contain ARP&RETAILS in the pattern.
System.Text.RegularExpressions.Regex.Replace(yourString,"(^[-\d]+).*?PO#_([^.]+).*","$1_$2")
Regards,
Try this:
(?<=PO#_)[^.^\s]+
It uses PO#_ as point of reference instead of just # and also takes the whole string until it hits a . or a space.
Thanks
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.