Regex Match All Characters Except Space (Unless In Quotes)

A regular expression to match all characters in a string except space (unless in quotes).

It is useful for developers to split a string into an array.

/\w+|"[\w\s]*"/

Matches:

  • Anything but space (unless in quotes)

See Also: