user3308470
user3308470

Reputation: 107

Regular expression match anything including newlines

I have string like:

/* Remove */
"REMOVE" = "Löschen \
";

And I have regular expression to match strings between " " = " "

"(\S+)"\s*=\s*"(.*?[\w\r\n]).*?";

What I have to add to match if string have more newlines in it, eg:

/* Remove */
"REMOVE" = "Lös \
ch \
en \
";

Upvotes: 1

Views: 7192

Answers (3)

user4227915
user4227915

Reputation:

Maybe this:

(.*)"\s*=\s*"((?:.|\n)*)

Regex live here.

Upvotes: 0

anubhava
anubhava

Reputation: 785156

You can use this regex:

"(\S+)"\s*=\s*"([^"]*)";

RegEx Demo

[^"]* is negation pattern that will match any character (including newline) except a double quote.

Upvotes: 1

Kasravnd
Kasravnd

Reputation: 107287

You can just use (.*?) and a dotall flag with which makes the dot match newline characters too :

(?s)"(\S+)"\s*=\s*"(.*?)"

See demo https://regex101.com/r/vM3tG6/2

Upvotes: 2

Related Questions