How to extract the string using regex

Hi Team,
Could you please help me to extract the below string using regex
String1:
Sample Sink Via Terms
1G47983657 ABC GROUND KET 10 DAYS
using regex we should select the 1947983657 (this sting is not fix length)
sometimes we are getting string like below
String2:
Sample Sink Via Terms
ABC1 GROUND KET 10 DAYS
using below regex to extract but its working in scenario 1 as expected but string2 it selecting ABC1 which is not expected. Could someone help me one this
(?<=Sample\s.+\r?\n)(\w*\d+\w*)

Hi,

How about the following pattern?

(?<=Sample\s.+\r?\n)(\d\w*\d)

Regards,

Hi

Can we try with a simple SPLIT method if it’s fine

Like this

Stroutput = If(String.IsNullOrEmpty(Split(Strinput.ToString,”ABC”)(0).ToString.Trim),String.Empty, Split(Strinput.ToString,”ABC”)(0).ToString.Trim)

Cheers @Srini_M

It extracting the ABC1 from string2. it should not select ABC1

Hi,

In my environment, the expression returns empty in String2 because its pattern starts with \d and not match ABC1. Can you try it again?

Regards,