Re: Interesting little regex

Bart Lateur <[email protected]>
Newsgroups gmane.comp.lang.perl.fun
Organization Me, Myself and I
Message-ID <[email protected]>
On Thu, 23 Feb 2006 13:02:32 -0500, Uri Guttman wrote:

>  AY> $text =~ s{(
>  AY>              (\b\w+(?:['-]+\w+)*\b)
>
>why the multiple ['-] inside the words? could those chars ever begin or
>end words? so just [\w'-]+ should be fine there.

That reminds me, only earlier today I looked at the word frequency
counter code in perlfaq6.


<http://perldoc.perl.org/perlfaq6.html#How-can-I-print-out-a-word-frequency-or-line-frequency-summary%3f>

I'm a bit puzzled by the comment:

	while ( /(\b[^\W_\d][\w'-]+\b)/g ) {   # misses "`sheep'"
	    $seen{$1}++;
	}

I'm wondering why they do it this way...

-- 
	Bart.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.