How to get specific text from a full string variable

Hi everyone,

Is there any way other than screen scrapping, get text to get specific text from a full string variable.

this is the example string variable


NME - John
ADS - Address
EMP - 462
DS - V38390004068/AG0
CI - W38C95035000/49

I need only to get 462 and V38390004068 from this string variable. The values keeps on changing and the text position may also change. Is there any way we can specifically get these outputs only.

Thanks in Advance.

Try this regex:

System.Text.RegularExpressions.Regex.Match( TextVal,"\d+(?=\s*DS)").Value

1 Like

Thank you for the replay.
What is the Textval is it varibale or text to search

Hi @Sugumar8785,

The expression u provided is returning 462 how to do the same for DS and CI values?

Thank you.

@batBot

For EMP:
System.Text.RegularExpressions.Regex.Match( TextVal,"\d+(?=\s*DS)").Value

For DS:
System.Text.RegularExpressions.Regex.Match( TextVal,"[a-zA-Z 0-9 /]+(?=\s*CI)")

For CI:
System.Text.RegularExpressions.Regex.Match( TextVal,"(?<=CI - ).*")

1 Like

@batBot If it has helped you, please mark it as solution.

@Sugumar8785

Thank you for the regex solution

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