Regular Expressions 101

Community Patterns

There does not seem to be anything here

Community Library Entry

1

Regular Expression
ECMAScript (JavaScript)

/
(\w+\s*\n*=\s*\n*)\{\n*\s*("([^"]*)"|'([^']*)')\n*\s*\}
/
gm

Description

Matches string properties that unnecessarily use brackets in React components.

NOTE: If you're looking to harmonise your quote usage, use this substitution input: $1"$3$4"

But be aware that strings that use single quotes inside double quotes or vice-versa will break!!!

Submitted by Nathanthanthan - 3 months ago (Last modified 22 days ago)