Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
ECMAScript (JavaScript)

Description

match one or more contiguous white space characters in a string.
can be used in JS, for example, to replace any white space characters (tab, space, newline), as well as multiple contiguous WS chars, with a single space character. var text = “1 2 \t \n 3”; text = text.replace(/\s+/g, ' '); // result: text == ‘1 2 3’

Submitted by anonymous - 3 years ago