Regex to get the required value

MW# 100166-197290
MW# SDHH01124

i want the output as 100166-197290 MW# will remain constant always

another document has MW# SDHH01124
i want the output as SDHH01124

i want always the text to retrieved after MW#

1 Like

Hi @T_Y_Raju

Try this regex:

Hope it helps!!

1 Like

Hi @T_Y_Raju

Try this regex

In both the cases it will get extracted.


1 Like


1 Like

Hey @T_Y_Raju
try this:
System.Text.RegularExpressions.Regex.Match(inputString, "MW#\s+(.*)").Groups(1).Value

1 Like

Hello @T_Y_Raju

You have a few options already but I have accounted for when there may be characters on the same line after the required text.

Test out the pattern here



1 Like

@T_Y_Raju You can follow this regex

hello @T_Y_Raju
you can try

this can be used for dynaic prefix.

hope it will help you.
Dheerandra Vishwakarma