How to get the string using regex pattern

Hi Team,
I need to extract the string using regex
Input string1: S No: 100-18675364
Input String2: S No: 1A2984836583
Regex pattern:(?<=S\s+No:\s*)(\w*\d+\w*|\d+)

using the above regex am able to extract the input string 2 and from input string 1 am getting till 100 , its not picking the after hypen(-). Could some one help me on this.

Hi,

How about the following pattern?

(?<=S\s+No:\s*)[-\w]+

Regards.

You can use this pattern:

(?<=S\s+No:\s*)([A-Z0-9-]+)

Inside [ ] you can specify exactly which characters you need.

if not mistaken \w is equilevant to [a-zA-Z0-9_]

Maybe you don’t want to capture underscore (_)

Thankyou, \w working fine.

Also, i have one more text
Date SNO #
09/22/2021 238258-00

How to get the 238258-00 using regex?

Thankyou for the quick response. Its working fine

Date SNO #
09/22/2021 238258-00

How to get the 238258-00 using regex?

You can try the following expression:

(?<=\/\d{4}\s)[-\w]+

image

Hi, wants to take preceding token also to identity that in the text file. How to get along with preceding token.

thanks for quick help.

String1:
simple text sample sample Group, sssustomer SO # Page #
565 E hjfguy wve 89876757 1 of 1

need to extract 89876757 from below string1:
String2:
S final 5.09
need to get the 5.90

can u also give me any website we can try to create the expression.

@Srini_M

               \d{8}
               \d.*

What do you mean by preceding token?