user20224716
user20224716

Reputation:

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

Upvotes: 0

Views: 51

Answers (1)

NullVoid
NullVoid

Reputation: 847

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.

Upvotes: 0

Related Questions