Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How To Get The Text Inside The Quotation Marks Using RegEx

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading