How to get the specific number from the text

Hi Team,

I need to extract the specific text from a string.

Example - “Putta sri sai rishik
{1:gerwbvhcnijxofb}
:20:SBI1234567890
:79:09876543
AMOUNT:9999
Value:0909”

Result - SBI1234567890

Here :20: is the only common anchor but after that we are not sure how much length number will come !!

Thanks :slight_smile:

CC @lrtetala

Help Me if you were available !!

Hi @Putta_Sri_Sai_Rishik_Chow

Input="Putta sri sai rishik
{1:gerwbvhcnijxofb}
:20:SBI1234567890
:79:09876543
AMOUNT:9999
Value:0909"

Output= System.Text.RegularExpressions.Regex.Match(Input,"(?<=20\:)[A-Z]*\d*").Value

Regards

Hi @Putta_Sri_Sai_Rishik_Chow

System.Text.RegularExpressions.Regex.Match(yourInputString, "(?<=:20:)[^\r\n]+").Value

Hi @Putta_Sri_Sai_Rishik_Chow

You can use the below regular expression to get the value after :20:

System.Text.RegularExpressions.Regex.Match(yourInputString, "(?<=:20:).*").Value

The above expression will take after the values of :20:

Hope it helps!!

hI @vrdabberu @pravallikapaluri

As im very new to regex…Thanks for ur help

Sometimes we are getting the scenarios with combination of symbols like “-”, “.” ,“/” (attached text below)

thriesh oouhunbgbPAY
{1:,KJHJDGFXCVIUTG8765R}{2:POIFUHCVBN9087546R}
:20:UYHHG-865445

thriesh oouhunbgbPAY
{1:,KJHJDGFXCVIUTG8765R}{2:POIFUHCVBN9087546R}
:20:UYHHG/8654.45

Thanks

@Putta_Sri_Sai_Rishik_Chow you can try this

System.Text.RegularExpressions.Regex.Match(yourInputString, "(?<=:20:).*").Value

@Putta_Sri_Sai_Rishik_Chow

Hi @Putta_Sri_Sai_Rishik_Chow

Try the above regex. This will work all the above scenarios

Output= System.Text.RegularExpressions.Regex.Match(Input,"(?<=20\:)[A-Z].*\d*").Value

Regards

Hello @Putta_Sri_Sai_Rishik_Chow

Cheers!!

Hello

You can learn more about regex here:

Cheers

Steve

@Putta_Sri_Sai_Rishik_Chow

System.Text.RegularExpressions.Regex.Match(str,“(?<=20:).*”).Value

Cheers!!

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