Regex pattern to extract address from string

Hello guys Please I would love to extract the highlighted address from the string . The address is always going to start the string and end with a zip code as seen


thanks in advance

HI,

How about the following expression?

System.Text.RegularExpressions.Regex.Match(yourString,"^.*?\b\d{5}\b").Value

This assumes zip code is 5 digit.

OR, if “Phone:” always follows Address, the following might be better.

System.Text.RegularExpressions.Regex.Match(yourString,"^.*?(?=Phone:)").Value

Regards,

2 Likes

HI @MasterOfLogic

How about this Regex expression

System.Text.RegularExpressions.Regex.Match(yourString,".*(?=\sPhone:)").Value

image

You can also try with Split expression

Split(YpourString,"Phone")(0)

image

Regards
Gokul

Hello @MasterOfLogic ,
Try this Regex

System.Text.RegularExpressions.Regex.Match(yourString,".*(?=\sPhone:)").Tostring.Trim

System.Text.RegularExpressions.Regex.Match(YourString,".*\D\s\d{4,8}").Tostring.Trim

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