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:
(?<=[A-Z]+\#\s+).*

Hope it helps!!

1 Like

Hi @T_Y_Raju

Try this regex
(?<=MW\#\s+).*

In both the cases it will get extracted.

Regards

1 Like

@T_Y_Raju

(?<=MW#\s)\w+.*\d+
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.
image

Test out the pattern here

Cheers

Steve

1 Like

@T_Y_Raju You can follow this regex
image
(?<=MW#\s+)[A-Z0-9-]+

hello @T_Y_Raju
you can try


this can be used for dynaic prefix.

hope it will help you.
Regards,
Dheerandra Vishwakarma