Jason Dusek wrote:

Hi Jason,

I'm redirecting this to the list, so that all can participate in the
discussion.  Folks have found that it works better that way.  You get
input from a much broader range of perspectives.

> On Wednesday, November 19, 2003, at 02:00 AM, R. Joseph Newton wrote:
>
>      s/\buniq\b/hyd_uniq/
>
>      Joseph
>
> The uniq() function can be called like:
>
> monkey_eats = fruits(uniq(fruits))
>
> Would your method catch a uniq() right inside of parentheses?

That regex is totally blind to parens.  It sees them only as non-word
characters, constituting a word boundary:

Greetings! E:\d_drive\perlStuff>perl -w
my $str = 'fruits(uniq(fruits))';
if ($str =~ /\buniq\b/) {
   $str =~ s/(.*)\buniq\b(.*)/$2uniq$1/;
   print "$str\n";
}
^Z
(fruits))uniqfruits(

I don't know about underscores, though.  Let's see:

Greetings! E:\d_drive\perlStuff>perl -w
my $str = 'fruits_uniq_fruits))';
if ($str =~ /\buniq\b/) {
   $str =~ s/(.*)\buniq\b(.*)/$2uniq$1/;
   print "$str\n";
} elsif ($str =~ /\b(.*)\b/) {
   print "$1\n";
}
^Z
fruits_uniq_fruits

Nope.  Underscores don't define word boundaries.  Since they can be used
in Perl identifiers, they are considered word characters.

Joseph



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to