Regular Expressions 101

Community Patterns

match arguments similar to shell, supports quoted string

1

Regular Expression
ECMAScript (JavaScript)

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

Description

first group matches quoted strings second group plain text, arguments are separated with a space. example: "this is a "string"" thisisnot "another "string" with a backslash "\"" just replace " with " after matching.

Submitted by anonymous - 9 years ago