Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
.+\.{a-z}+$
/
gm

Description

.+.{a-z}+$

/ .+.{a-z}+$ / gm .+ matches any character (except for line terminators)

  • Quantifier — Matches between one and unlimited times, as many times as possible, giving back as needed (greedy) . matches the character . literally (case sensitive) {a-z matches the characters {a-z literally (case sensitive) }+ matches the character } literally (case sensitive)
  • Quantifier — Matches between one and unlimited times, as many times as possible, giving back as needed (greedy) $ asserts position at the end of a line Global pattern flags g modifier: global. All matches (don't return after first match) m modifier: multi line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)
Submitted by anonymous - 5 years ago