Phoenix.pm: Sorry for the dup

intertwingled intertwingled at qwest.net
Tue Nov 26 16:13:54 CST 2002


At 12:48 PM 11/26/02 -0800, you wrote:
>
>Ack, sorry for the duplicate. I thought my message was rejected again.
>Too many email aliases ;)
>
>> s{(\w+)\s*=?\s*(['"]?)(.*?)(?<!\\)\2}{$hash{$1} = $3;''}ge;
>> foreach my $i (keys %hash) { $hash{$i} =~s/\\//g }
>
>This prolly needs explained. 
>
>Globally, we're matching a word, followed by any amount of space, an optional
>equal sign, any amount of space, an optional quote character, anything at
all*, 
>and then whatever we matched for the quote character, which may be nothing.
>However, the second time, we don't just match the quote character - we put
>a conditional in front of it - (?<!\\) only lets the REGEX continue on
matching
>if the previous thing was NOT a \. We need a \ to escape our \. This is a
>"zero width negitive look-behind" asserition. We require (assert)
something: the it
>isn't true (negitive) that previous thing (look-behind) is \.
>
>* "Anything at all" is matched non-greedily, so it stops as soon as the
next thing
>in the regex would match.
>
>After that, we just have to remove the now redundant \'s from our values and
>we're good to go.
>
>-scott
>
>
>

Please do not let it happen again
Please do not let it happen again


--
even the safest course is fraught with peril




More information about the Phoenix-pm mailing list