Kshitiz Sharma
Kshitiz Sharma

Reputation: 18597

Regex ignores quote character

I have this text -

[Event "F/S Return Match"]

This is my regex -

\[.*"

The match is -

[Event "F/S Return Match"

I was expecting -

[Event "

Why is the first quote being ignored?

Upvotes: 4

Views: 65

Answers (1)

anubhava
anubhava

Reputation: 785058

Make it non-greedy regex:

\[.*?"

Or better use negation:

\[[^"]*"

Upvotes: 4

Related Questions