Hi Guys n Gals,

I have found some seemingly strange behavior that may
be of interest to this list.

My assumption was that the \b pattern in a regex would
always match the beginning and end of a string (as
documented in the perlre page). However on my build of
5.8.7 this is not the case if the character being
matched at the beginning or the end is a
"meta-character" ie. quotemeta would escape it. Also
note that escaping the charcter doesn't seem to make a
difference.

Here are some more examples, run in `perl -d -e 1`:
  DB<26> p '/' =~ m"\/\b";

  DB<27> p '/' =~ m"\/";  
1
  DB<28> p 'a' =~ m"a\b"; 
1
  DB<29> p 'a' =~ m"\ba\b";
1
  DB<32> p '/' =~ m"\/\b";                            
                          

  DB<33> p '/' =~ m"/\b"; 

  DB<34> p '/' =~ m"/";  
1
  DB<35> p 'a/' =~ m"a/";
1
  DB<36> p 'a/' =~ m"a/\b";

  DB<37> p 'a/' =~ m"\ba/";
1
  DB<39> p '/' =~ m"^/";
1
  DB<40> p 'a/b' =~ m"\b/"; 
1
  DB<41> p '/' =~ m"\b/";  

  DB<42> p '//' =~ m"\b/";

  DB<43> p '//' =~ m"\b|\W/";
1
  DB<44> p '/' =~ m"\b|\W/"; 

  DB<45> p '/' =~ m"^|\b|\W/";
1
  DB<46> p '/' =~ m"\b|\W|^/";
1


Maybe this is not a bug, and this is just another
nuance of regexs' that I have not learned, but it
looks very fishy.

Any thoughts/wisdom?

Thanks!

-Carl
 
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to