|
|
Choosing A Webhost: |
Re: [Boston.pm] '/' =~ m"\/\b"; (bug?): msg#00032lang.perl.perl-mongers.boston
On 11/15/06, Carl Eklof <carleklof-/E1597aS9LQAvxtiuMwx3w@xxxxxxxxxxxxxxxx> wrote: > 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. Actually that is NOT as documented in the perlre page. And thoughts to the contrary are a misreading of the documentation. What the perlre page says is that there is an imaginary \W at the beginning and end of the string. The result is that if the first character in the string matches \w, then \b will match at the start, and if the last character matches \w, then \b will match at the end. However if the first and/or last characters do *not* match \w, then that is not a word boundary and \b will not match there. [examples snipped] > Maybe this is not a bug, and this is just another > nuance of regexs' that I have not learned, but it > looks very fishy. It is definitely not a bug. If the string is "...", then there are no words, hence no word boundaries, therefore \b should not match at all. (And it does not.) Conversely if the string is "hello" then there is a word, and it has boundaries, and those boundaries should be matched by \b. (And they are, thanks to the "imaginary characters" discussed in the documentation.) > Any thoughts/wisdom? See above. Cheers, Ben
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: [Boston.pm] '/' =~ m"\/\b"; (bug?), Ronald J Kimball |
|---|---|
| Next by Date: | Re: [Boston.pm] '/' =~ m"\/\b"; (bug?), Carl Eklof |
| Previous by Thread: | Re: [Boston.pm] '/' =~ m"\/\b"; (bug?), Ronald J Kimball |
| Next by Thread: | Re: [Boston.pm] '/' =~ m"\/\b"; (bug?), Carl Eklof |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |