I'd suggest combing for the regex instead of combing and then grepping with the regex:
say + "abcrd-12.3.4".comb(/<alnum>/); though from the problem question it sounds a lot more like what todd wants is my $input = "abcrd-12.3.4"; my $letters = $input.comb(/<[a..z]>/); my $numbers = $input.comb(/<[a..z 0..9 .]>/); say "the string $input has $letters letters and $numbers numbers and periods."; On 15/05/18 09:57, JJ Merelo wrote: > Well, > say + "abcrd-12.3.4".comb.grep: /<alnum>/ > will give you that, but > say + "abcñé-12.3.4".comb.grep: /<alnum>/ > will yield the same result. > Roman or other kind of numerals are excluded, though... > > > El mar., 15 may. 2018 a las 9:44, ToddAndMargo (<toddandma...@zoho.com > <mailto:toddandma...@zoho.com>>) escribió: > > On 05/15/2018 12:37 AM, JJ Merelo wrote: > > Hi, > > > > El mar., 15 may. 2018 a las 9:31, ToddAndMargo > (<toddandma...@zoho.com <mailto:toddandma...@zoho.com> > > <mailto:toddandma...@zoho.com <mailto:toddandma...@zoho.com>>>) > escribió: > > > > >> El mar., 15 may. 2018 a las 8:32, ToddAndMargo > > (<toddandma...@zoho.com <mailto:toddandma...@zoho.com> > <mailto:toddandma...@zoho.com <mailto:toddandma...@zoho.com>> > > >> <mailto:toddandma...@zoho.com > <mailto:toddandma...@zoho.com> <mailto:toddandma...@zoho.com > <mailto:toddandma...@zoho.com>>>>) > > escribió: > > >> > > >> Hi All, > > >> > > >> Do we have one of those sweet functions that will > > >> allow us to look at a string and give us back the > > >> count of how many "letters" and/or "numbers" are > > >> in a string? > > >> > > >> And are decimal points considered numbers or letters? > > >> > > >> Many thanks, > > >> -T > > >> > > > > On 05/14/2018 11:44 PM, JJ Merelo wrote: > > > IN Perl 6, it's a bit more complicated. Do you want to count > > graphemes > > > or codepoints? > > > > > > > I want to know the number of letters A..Z (ascii 65..90), a..z > > (ascii 97..122), > > > > and the numbers of numbers 0..9 (ascii 48..57) and decimal > points > > (ascii 46). > > > > > > Once again, that's not so simple. You don't want other kind of > numbers? > > Would á count as one a and one '? > > > > > > I won't have an weird characters in these stings, such as > !@#$^&%( > > > > > > Whoa, whoa, whoa, you calling á and ñ weird? > > > > Anyway, if that's what you want, just filter those precise > graphemes and > > count the number of graphemes. > > > > Cheers > > > > JJ > > "abcrd-12.3.4" would be five letters, six numbers, and one > I don't care. > > > > -- > JJ