Regex to fetch next string after a specific word

Hi everyone, hope you are doing well,

I have a string “1 1 EA 2-80lpo241 Rev. NC”,
here I need to fetch any text available right after EA, in this case which is “2-80lpo241”

Some Example are:
1 2 EA 2-416819-02 Rev. B CLOSED => should fetch “2-416819-02”
3 1 EA 540-OI 1358484=> Should fetch “540-OI”

P.S The string need to fetch can contains alphanumeric values and special characters as well.
Thank You

@Daniyal_Tahir

Try this:

Hi @Daniyal_Tahir
Try this:

Input= "1 1 EA 2-80lpo241 Rev. NC
1 2 EA 2-416819-02 Rev. B CLOSED
3 1 EA 540-OI 1358484"
Output= System.Text.RegularExpressions.Regex.Match(Input,"(?<=EA\s)[\d-]+[A-Za-z0-9-]+").Value

Hope it helps!!

Thankyou for the response,
The String may contain small letter as well as some special characters other than “-”

Thankyou for the response, It works with any kind of characters available in next keyword.

we missed but solve it here for any letter:
grafik

But suggest also to go with @monsieurrahul 's pattern

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