Home > front end >  How To Get The Text Inside The Quotation Marks Using RegEx
How To Get The Text Inside The Quotation Marks Using RegEx

Time:11-12

I have a random generated text with quotation marks and inside it there has randomally generated words with numbers combined

This what i have done so far:

(?<!["])(")\w 

https://regex101.com/r/aIXAnk/3

CodePudding user response:

If you do not want to use capturing groups, you can do this:

(?<=["])\w ?(?=["])

It matches a string with a double quote in front of it and a quote behind it.

Also, it's better to use the ? to make it not match more than you want.

Please note that if you have 3 or more quotation marks it may return unexpected results.

The best way is to use capturing groups like that:

"(\w ?)"

and grab the content by capturing group 1.

  • Related