6

When searching with a regex I want .* to match line separators (\n). To do it you should add s flag, but I can't quite figure out how to do it. Is there a way to add regex flags in PhpStorm?

0

1 Answer 1

10

Use a DOTALL inline modifier option:

(?s).*
^^^^

This pattern means that all . to the right of the (?s) will also match line break chars.

Inline Modifier (?s)
In .NET, PCRE (C, PHP, R…), Perl, Python and Java (but not Ruby), you can use the inline modifier (?s), for instance in (?s)BEGIN .*? END. See the section on inline modifiers for juicy details about three additional features (unavailable in Python): turning it on in mid-string, turning it off with (?-s), or applying it only to the content of a non-capture group with (?s:foo)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.