Regular Expressions 101

Community Patterns

Find any version of US country name in address string

1

Regular Expression
PCRE (PHP <7.3)

/
(\b[u](nited)?( )?[s](tates)?(a|( of america))?\b)|(u\.s\.(a\.)?)$
/
i

Description

Given a string that represents a location in the USA, find any version of the USA country name as one would expect at the end of that string. Does not match on if it finds it elsewhere such as a freeway name or the "us" in the city of "Russellville".

Submitted by Bobby - 9 years ago