[thelist] regexp question

Sam-I-Am sam at sam-i-am.com
Thu Mar 29 10:04:49 CST 2001


I'm trying to match repeated characters. And capture how many times they
are repeated. 
e.g given string '--------_____' I want to know that there are 8 '-'
characters, followed by 5 '_' characters. 
I even seem to recall this being one of the first examples in on of
o'reilly's perl books... but can't find it now. 

I've been trying variations on this theme
/(.)+/	# which *I* read as any single character repeatd 1+ times (but
the regexp engine reads as any number of any characters except newline

/(.)+\1/ # again, I read this as any single character repeated 1+ times,
followed by any character except the one I first matched...

anyway, so none of this works as expected (surprise! isn't that the joy
of regexp :)
Anyone have a clue??

thanks
Sam




More information about the thelist mailing list