Regex To Match Non-blank And Non-Empty String

A regular expression to match non-blank and non-empty strings. Can be used to extract all content without blank lines and empty strings from the document.

/(.|\s)*\S(.|\s)*/

Matches:

  • ABC
  • A B C
  • A+B

Non-matches:

  • Any blank lines and empty strings

See Also:

Regex Is Copied!