Get the content after specific word in a string

Hello,

I wanted to get the content after the specific Text in a string.

Example:
The string value is as below.

Serial Number: 0000000001 Customer no.: 001231022067

In this example, I wanted to get the Customer no.
(i.e.) The output should be 001231022067

Requesting for help.

@shahidh.aqeel.shahul

Assign customerNumber = System.Text.RegularExpressions.Regex.Match(inputString, “(?<=Customer no.:\s*)\d+”).Value

CustomerNumber is String type.

Hope this helps you


output
image
Refer this:System.text.RegularExpressions.Regex.Match(inputstring,“(?<=Customer no.:\s+)\d+”).Value

image

Use this in “find matching patterns acitivity”

Regards

Hi @shahidh.aqeel.shahul

You can try with Regular expression

System.text.RegularExpressions.Regex.Match(YourString,“(?<=Customer\sno\D\D\s)\d+”).Tostring

Regards
Gokul

hi,@shahidh.aqeel.shahul

For Customer No.:
System.text.RegularExpressions.Regex.Match(Sample,“(?<=Customer no.:).*”).Value.Trim

For Serial Number:
System.text.RegularExpressions.Regex.Match(Sample,“(?<=Serial Number:)\s[\d]+”).Value.Trim

Hope it Helps!!

Hello

Another option :blush:

(?<=Customer no[^\d]+)\d+

image

Learn Regex with my MegaPost:

Cheers

Steve

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