Regular Expressions 101

Community Patterns

Community Library Entry

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 - 10 years ago