mrpeabody has asked for the wisdom of the Perl Monks concerning the following question:
522 $ perl -we'my $x = "bar"; print "yes" if "fooBarbaz" =~ /\u$x/x' yes
This doesn't:
523 $ perl -we'my $x = "bar"; print "yes" if "fooBarbaz" =~ /\u $x/x'
In other words, the \u operator can't be separated from the following atom by whitespace, even under \x. If it is, it silently fails to have an effect. The same thing happens if you use the string "bar" directly instead of $x.
Perhaps this is just an artifact of \u being more of a double-quote interpolation operator, as opposed to a regex operator proper. But it seems odd (wrong) that "\b $word" works fine while "\u $word" fails.
Is there a chance of getting this changed, or is there some good reason why it works this way?
This is perl, v5.8.8 built for cygwin-thread-multi-64int
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Regex bug? (/u not cooperating with /x) (string vs regex)
by tye (Sage) on Oct 24, 2007 at 05:20 UTC | |
by mrpeabody (Friar) on Oct 24, 2007 at 05:49 UTC | |
Re: Regex bug? (/u not cooperating with /x)
by ikegami (Patriarch) on Oct 24, 2007 at 05:05 UTC | |
Re: Regex bug? (/u not cooperating with /x)
by duff (Parson) on Oct 24, 2007 at 04:18 UTC | |
Re: Regex bug? (/u not cooperating with /x)
by GrandFather (Saint) on Oct 24, 2007 at 04:23 UTC | |
Re: Regex bug? (/u not cooperating with /x)
by runrig (Abbot) on Oct 24, 2007 at 04:19 UTC |