Bolognium on Nostr: npub18yve5…jxxyn Oh, interesting. That's very different from Perl/JavaScript then, ...
npub18yve5f33hyqq35t3y3xu72t9x33pfdznd0kq78lf73wkxchzr5hsmjxxyn (npub18yv…xxyn) Oh, interesting. That's very different from Perl/JavaScript then, which uses /s (confusingly referred to as "single line" mode sometimes) to make . match newlines.
The main point, however, is that /x ignores whitespace in the regex, not in the string it is matching against. That is, instead of /(?<test1>.*stage\(.Test.\)\s+\{[^}]+\})/, you can write /(?<test1> .* stage\( . Test . \) \s+ \{ [^}]+ \} )/x or even:
/ (?<test1>
.*
stage\( . Test . \)
\s+
\{ [^}]+ \} # a block in curly braces
)
/x
And it all does the same thing since /x mode effectively strips whitespace/comments from the regex before matching.
The main point, however, is that /x ignores whitespace in the regex, not in the string it is matching against. That is, instead of /(?<test1>.*stage\(.Test.\)\s+\{[^}]+\})/, you can write /(?<test1> .* stage\( . Test . \) \s+ \{ [^}]+ \} )/x or even:
/ (?<test1>
.*
stage\( . Test . \)
\s+
\{ [^}]+ \} # a block in curly braces
)
/x
And it all does the same thing since /x mode effectively strips whitespace/comments from the regex before matching.