Regex 101 Exercise I9 – Count the number of matches


Regex 101 Exercise I9 – Count the number of matches


Given a string like:


# # 4 6 # # 7 # 45 # 43 # 65 56 2 # 4345 # # 23


 


Count how many numbers there are in this string


 

Comments (12)

  1. PhilipTaron says:

    perl -ne "$a++ while m/d+/g; print $a;"

  2. Here’s my entry in the Obfuscated Perl contest:

    perl -ne "print 0+@{[/d+/g]}"

  3. Obfuscated Perl entry #2… mmm… signal-to-noise ratio of 7-to-1 😉

    perl -pe "$_=@{[/d+/g]}"

  4. Regex 101 Exercise I9 – Count the number of matches

    Given a string like:

    # # 4 6 # # 7 #…

Skip to main content