in reply to How to count the number of chars in a string
Not sure why?
I'd suggest better code if I new what your goal is.
No need for weird negated character classes.
DB<6> x $_='12a3b';/\d/g 0 1 1 2 2 3 DB<7> x $_='12a3b';/[ab]/g 0 'a' 1 'b'
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
*) Character_(computing) include letters, numerical digits, common punctuation marks (such as "." or "-"), and whitespace.
In case you are only counting single characters and not combinations consider using tr instead, like described in Re: Some odd ambiguity in this regex
|
|---|