Regular Expression To Match Whitespace

A regular expression to match the first whitespace found in a term or sentence (exclude newlines).

/[^\S\r\n]/

Matches:

  • Regex [WHITESPACE] Pattern
  • Regex [WHITESPACE] Pattern [SECOND WHITESPACE] COM

Non-matches:

  • All other whitespaces except the first one.

See Also: