Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE2 (PHP >=7.3)

/
\s(?=[\s":{}])
/
g

Description

I use it so that I don't need to worry about formatting when working with unit tests in Kotlin, which means I don't worry too much about whether this is production quality, but it could be useful in other situations where the desire is to strip whitespace from a JSON object while protecting the values of stings which have whitespace.

Submitted by anonymous - 3 years ago