Regular Expressions 101

Community Patterns

Exact match of whole word or phrase in string

1

Regular Expression
PCRE (PHP <7.3)

/
^word\s.*|.*\sword$|.*\sword\s.*
/

Description

word in sentense - true sentense has a word - true There is a word in the sentense - true Sentense wordless - false Sentense is empty - false words are in the sentense - false Sentense has words - false etc.

Submitted by Denisenko Artem - 8 years ago