Skip to content

Conversation

@wesQ3
Copy link

@wesQ3 wesQ3 commented Jun 25, 2025

In Perl 5.26+, the regex quotelike operator accepts a second x modifier to allow whitespace inside of character classes. This can improve readability of complex character classes.

Currently TM Perl syntax does not parse extended regex with /xx correctly when broken across multiple lines.

# single line is ok
my $single = $foo =~ s/[ \N{NO-BREAK SPACE} \r \n {} " ]/ /grxx;
# multi-line highlights ok without second x
# this is syntactically invalid but useful for comparison
my $multi  = $foo =~ s/[
        \N{NO-BREAK SPACE}
        \r \n
        {}
        "
        ]/ /grx;
# multi line extended breaks when second x is added
my $multi_xx  = $foo =~ s/[
        \N{NO-BREAK SPACE}
        \r \n
        {}
        "
        ]/ /grxx;
# rest of file is now broken because of unmatched second x

A simple adjustment to the extended regex 'end' condition to allow the second x fixes the parsing error.

5.26+: End patterns now allow the second 'x' to use extended regex with
whitespace in character classes.

See https://perldoc.perl.org/perlre#/x-and-/xx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant