Regular Expressions 101

Community Patterns

Command line with escape

0

Regular Expression
PCRE (PHP <7.3)

/
((?<!\\)"(?:[^"]|(?:\\"))+(?<!\\)"|[^\s"]+)
/
g

Description

splits into command arguments:

  • spaces split
  • quotes keep spaced texts together
  • " escapes the quote
Submitted by Skycoder42 - 8 years ago