Regular Expressions 101

Is String having proper quotes around it

Open Workspace
  • JavaScript
  • Match
-1

Regular Expression

/
^("([^"]|\\")*?")$|^('([^']|\\')*?')$|^(`([^`]|\\`)*?`)$
/
gm

Description

  • Language : Javascript

  • Description : This will helpful for validating contents from a text editor where all the values are string and you need to verify that string must be a single string having quotes around it.

  • Note : This regex is best applicable by trimming the string before checking with this regex

Submitted by PranomVignesh<pranomvignesh@gmail.com>