Regular Expressions 101

Community Patterns

Argument:Value, exclusively

0

Regular Expression
PCRE2 (PHP >=7.3)

/
\b((?!^\d+)^.*?)\:([a-zA-Z0-9_-]*)\b
/
gm

Description

Attempt to only match Argument:Value pairs, but exclude numeric:numeric (for instance a time value format) using negative lookahead.

Can be used for console arguments, examples:

  • USE_DEV:true. => valid / match
  • 07:00 or 07:00:00 => invalid / no match
Submitted by Theo V - 2 years ago