Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Escape quotes and matched backslashes in perl match results #2

Merged
merged 1 commit into from

2 participants

@purcell

When matching text containing backslashes, e.g. "\n", the "Group" output will display this as a newline. To prevent this, we have perl escape any backslashes in the group output so that 'read will handle the expression correctly.

Further, if the matched text contains double quotes, the resulting sexp printed by the perl program is invalid, and so the *Groups* buffer is empty. This commit also fixes this second issue.

@purcell purcell Escape quotes and matched backslashes in perl match results
When matching text containing backslashes, e.g. "\n", the "Group" output will display this as a newline. To prevent this, we have perl escape any backslashes in the group output so that 'read will handle the expression correctly.

Further, if the matched text contains double quotes, the resulting sexp printed by the perl program is invalid, and so the `*Groups*` buffer is empty. This commit also fixes this second issue.
86577ce
@purcell

Bump. :-)

@jwiegley jwiegley merged commit 3c2dd84 into jwiegley:master
@purcell

Thanks John. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 20, 2012
  1. @purcell

    Escape quotes and matched backslashes in perl match results

    purcell authored
    When matching text containing backslashes, e.g. "\n", the "Group" output will display this as a newline. To prevent this, we have perl escape any backslashes in the group output so that 'read will handle the expression correctly.
    
    Further, if the matched text contains double quotes, the resulting sexp printed by the perl program is invalid, and so the `*Groups*` buffer is empty. This commit also fixes this second issue.
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 1 deletion.
  1. +3 −1 regex-tool.el
View
4 regex-tool.el
@@ -94,7 +94,9 @@ while ($line =~ m/%s/mg) {
print \"(\", length($`), \" \", length($&), \" \";
for $i (1 .. 20) {
if ($$i) {
- print \"(\", $i, \" . \\\"\", $$i, \"\\\") \";
+ my $group = $$i;
+ $group =~ s/([\\\\\"])/\\\\\\1/g;
+ print \"(\", $i, \" . \\\"\", $group, \"\\\") \";
}
}
print \")\";
Something went wrong with that request. Please try again.