php.net help

  • , offset: (optional)

php.net help

  • , offset: (optional)

php.net help

php.net help

Regular Expression

Replacement

String / Subject

Results

You can save and share this session to help others to find a solution.

Pattern Modifiers
  • i PCRE_CASELESS
  • m PCRE_MULTILINE
  • s PCRE_DOTALL
  • x PCRE_EXTENDED
  • e (Disabled for this site)
  • A PCRE_ANCHORED
  • D PCRE_DOLLAR_ENDONLY
  • S Extra analysis
  • U PCRE_UNGREEDY
  • X PCRE_EXTRA
  • u PCRE_UTF8
Pattern Syntax
  • \ general escape character
  • ^ assert start of subject (or line, in multiline mode)
  • $ assert end of subject (or line, in multiline mode)
  • . match any character except newline (by default)
  • [ ] class definition
  • | start of alternative branch (OR)
  • (...) subpattern
  • ? extends the meaning of '(', also 0 or 1 quantifier
  • * 0 or more quantifier
  • + 1 or more quantifier
  • { } min/max quantifier, {n[,n]}
  • [^...] characters class negation
  • \a alarm, that is, the BEL character (hex 07)
  • \cx "control-x", where x is any character
  • \e escape (hex 1B)
  • \f formfeed (hex 0C)
  • \n newline (hex 0A)
  • \r carriage return (hex 0D)
  • \t tab (hex 09)
  • \xhh character with hex code hh
  • \ddd character with octal code ddd, or backreference
  • \d any decimal digit
  • \D any character that is not a decimal digit
  • \s any whitespace character
  • \S any character that is not a whitespace character
  • \w any "word" character
  • \W any "non-word" character
  • \b word boundary
  • \B not a word boundary
  • \A start of subject (independent of multiline mode)
  • \Z end of subject or newline at end (independent of multiline mode)
  • \z end of subject (independent of multiline mode)
  • \G first matching position in subject
  • \1-9 in-group back references
  • (?P<lbl>...) labelize subpatterns
  • (?:...) non-capture group
  • (?>...) Atomic group
  • (?=...) Positive lookahead
  • (?!...) Negative lookahead
  • (?<=..) Positive lookbehind
  • (?<!..) Negative lookbehind
  • (?(?=.).|.) if . then . else .
  • (?#...) Comment