Regular Expressions 101

Community Patterns

Match different types of quoted strings in Javascript

1

Regular Expression
ECMAScript (JavaScript)

/
^([^“”]+)|\s([^“”]+)|^("[^"]+")|\s("[^"]+")|^('.*')\s|\s('.*')\s|^('.*')$
/
ig

Description

The regex tries to match several types of quotations trying to avoid extreme cases. Bare in mind that this was developed for a specific use and thus some of the matches might not work for you.

Submitted by Shadi Lahham - 8 years ago