Need Regex below Values

Hi team,
need regex below two string values

String one str=“AMICA UNIONVILLE 13005”

Required Output =“AMICA UNIONVILLE”

String two str2=“AMICA UNIONVILLE (13005)”

Required Output =“AMICA UNIONVILLE”

note- these values are dynamic

please anyone help these regex

Regards,
Saikrishna

Hi @Mada_Sai_Krishna

Check the below regex:
[A-Z].*(?=\s+\d+|\s+\()

Regards

Hi @Mada_Sai_Krishna

[A-Z]+\s?[A-Z]+

in assign use in this way

System.Text.RegularExpressions.Regex.Replace( yourtext, "(\s\d+)|\s(\(\d+\))", "")

Hi @Mada_Sai_Krishna

Check the below syntax for better understanding:

System.Text.RegularExpressions.Regex.Match(str, "[A-Z].*(?=\s+\d+|\s+\()").Value.Trim()

image

Regards

Hi @Mada_Sai_Krishna

Try this

([A-Z ]+)

Regards,

Thank you for everyone

1 Like

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