Thee Cherry
Thee Cherry

Reputation: 131

If string includes and excludes?

Match requirement:
If String is between " AND includes \n

Example (catch YES include "s):

NO NO NO    "NO NO NO"  "YES YES
YES"    NO  "NO"

This Regex work a half:

\"((?!\").)*\"

This doesn't work as well:

\"((?!\").)*(?!.*\n)\"

Did try many cases, but found no solutions.

Upvotes: 0

Views: 58

Answers (1)

Unihedron
Unihedron

Reputation: 11051

Use this regex:

/"[^"]*\R[^"]*"/

Here is a regex demo!

Test case:

NO NO NO    "NO NO NO"  "YES YES
YES"    NO  "NO"

Match:

"YES YES
YES"

Upvotes: 2

Related Questions