Hi guys i need a Regex or some kind of string manipulation to get the correct output

Hi guys i need a Regex or some kind of string manipulation to get the correct output

Example of String

1.lorem ips22um lorem ipsu22m, lorem ipsum C23324/A245228, example
2. lorem i22psum lorem ip1231sum, lorem ipsum D122222

these 2 are the possibilities of the String i might encounter
the output i want to get from those is

Output:
if number 1 then : C23324 and A245228 then insert it into a list
if number 2 then D122222 and insert it on a list

thanks

Hi @Ahmad_Rais ,

More details on the extraction data would be helpful, but for now could you check with the below :

\w\d+

You could use Matches Activity to get all the matched values.

The below Expression should give you the Matched String values in an Array format . Use .ToList if required as a List.

matchesOutput.Cast(Of Match).Select(Function(x)x.Value.ToString).ToArray

note that the letter before the number is also random ,

will this still work?,

and how do i use regex and uipath im kinda lost on that aspect hehe

thank you

Hi @Ahmad_Rais

You can follow the @supermanPunch suggestion

Expression should bee

System.Text.RegularExpressions.Regex.Match(YourString,"\w\d+").Tostring

Regards
Gokul

Hi,

If you need to add extract strings to your list, the following might help you.

yourList = yourList.Concat(System.Text.RegularExpressions.Regex.Matches(yourString,"[A-Z]\d+").Cast(Of System.Text.RegularExpressions.Match).Select(Function(m) m.Value)).ToList

Regards,

Hi I have edited some of the string bcs i tested i might get the wrong output

Hi I have edited some of the string bcs i tested i might get the wrong output , i add some number which should not be inserted on the output

Can you share us the correct Input @Ahmad_Rais , Based on the input we have provide the solution.

If you have more template of input share with us.

image

Regards
Gokul

Hi Yoichi ,
i knew u will always help :slight_smile: ,
seems like this can work , i will try first

thank you

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.