in reply to Re: Re: Re: Re: Perlre interpretation required
in thread Perlre interpretation required
It will handle even the edge cases yours breaks on. Using the (?{}) stuff to remove the redundancy is a nice idea, but for this case isn't the best solution.#!/usr/bin/perl -wnl use strict; print; print join ' / ', map qq["$_"], m[\G ( ' (?: \\ . | '' | [^'] ) + ' | " (?: \\ . | "" | [^"] ) + " | (?: \\ . | [^'"] ) + ) ]gx; print "";
Update: Doubled the backslashes in the second piece of code.sub make_dequote_rx { my @char = map quotemeta, @_; my $chars = join '', @char; my $rx = join( ' | ', map(qq[$_ (?: \\\\ . | $_$_ | [^$_] ) + $_], @char), qq[(?: \\\\ . | [^$chars] ) +], ); return qr/\G ( $rx )/x; } my $dequote = make_dequote_rx qw(' ");
Makeshifts last the longest.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re^5: Perlre interpretation required
by BrowserUk (Patriarch) on May 04, 2003 at 09:43 UTC | |
by Aristotle (Chancellor) on May 04, 2003 at 13:35 UTC | |
by BrowserUk (Patriarch) on May 04, 2003 at 14:19 UTC | |
by Aristotle (Chancellor) on May 04, 2003 at 15:35 UTC |