Regular Expressions 101

Community Patterns

Community Library Entry

2

Regular Expression
ECMAScript (JavaScript)

/
^\s*(.*?)\s*$
/
gm

Description

Trim leading/trailing space on a string: do not use /gm flags.

Trim each line of a multiline string: use the /gm flag.

Submitted by https://github.com/naomik - 10 years ago