Regex expression to extract only numeric values separated by underscore

Hi all,
Need help with this.
Input string is “DM1_65_78109” OR SL1_78_72947".
Output should be 65_78109 or 78_72947
Any letter can be there.

HI @neha_malik

Use Assign activity
LHS - Create an variable
RHS - System.Text.RegularExpressions.Regex.Match(“Input string”,"(?<=[A-Z]{2}\d_)(\S.+)").Tostring

Regards
Gokul

Hi Gokul,
Thanx for your reply. But it’s not working… it’s giving empty value in the message box. Also, can you tell me what does this \S. stands for ?

Can you share the exact input file or text file@neha_malik

\S → It will get all the Non-White space character

.+ ->It is equal lent to * any number of character after \S

Regards
Gokul

Yeah… I can give some examples.
Input is DM1_813_1881 , output should be 813_1881
Input is DM2_793_1808 , output 793_1808
Input is DM1_SL1_609_604980 , output 609_604980

How about this one

Hi!

try this:

System.Text.RegularExpressions.Regex.Match(Input_str,"(?<=[^AZ-az]_).\S+\d)")

Regards,
NaNi

HI @neha_malik

Try this expression

Use Assign activity
LHS - Create an variable
RHS - System.Text.RegularExpressions.Regex.Match(“Input string”,"(?<=SL{1}\d_)[0-9_]|(?<=DM{1}\d_)[0-9_]").Tostring

Regards
Gokul

1 Like

Hi!

System.Text.RegularExpressions.Regex.Match(Input_str,"(/(?<=SL{1}\d_)[0-9_]*|(?<=DM{1}\d_)[0-9_].*)")

Output-

RegEx1

Regards,
NaNi

have a look on this pattern

grafik

And also:
grafik

Can you tell me what does this \S. stands for ?

grafik

have a look on the https://regex101.com/ page it gives also an explanation to the used patterns