How to extract particular string after special character or symbol is found

Hi team, I want to extract the string from given string if the particular symbol is found
E.g. I have string like : 3000432960_ART_001_GENERELL_AC_V0.1
Here I want to extract the string when first underscore is found. so the extracted string should be 3000432960.
Thanks in Advance!

HI @Rohit_Patil1

Checkout this expression

System.Text.RegularExpressions.Regex.Match(YourString,"^\d+(?=\_)").Tostring.Trim

image

Regards
Sudharsan

Thanks @Sudharsan_Ka for the response. Let me try

Hello @Rohit_Patil1
Try This

System.Text.RegularExpressions.Regex.Match(YourString,"^[\d]+").Tostring.Trim

image

Hi Users,

"[1]+(?=)"
Kindly Check this
[2]+(?=
)
image

if its correct mark as solution for other to use

thanks and regards

happy automation…


  1. ^_ ↩︎

  2. ^_ ↩︎

Hi,

How about the following expression?

image

System.Text.RegularExpressions.Regex.Match(yourString,".*?(?=_)").Value

Regards,

@Rohit_Patil1

Another way would be to use split string…irrespective of what the string is this would extract the values

Str.Split({"_"},StringSplitOptions.None)(0)

Cheers

1 Like

This is working @Gokul_Jayakumar . Thanks

Its working @Anil_G . Thanks for the help.

1 Like

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