codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  number of regex match  perl2user at 19:32 on Thursday, January 15, 2009
 

hi,
i'd like to know how to get the number of regexp matches a pattern returns
ex: if I have $_ = "fooFOObarBAR";$_ =~ /[a-z]/
it would return 6

thx

cvv3@yahoo.com

  Re: number of regex match  hermanningjaldsson at 20:00 on Thursday, January 15, 2009
 

my @instances = map { /[a-z]/g } "fooFOObarBAR";
my $instance_quantity = $#instances+1;




  Re: number of regex match  S_Flex at 13:04 on Friday, February 27, 2009
 

there are a lot of ways to do 1 think in perl, here is the way i would do it.

my $count = "fooFOObarBAR" =~ tr/[a-z]//;
print $count;

  Re: number of regex match  perl2user at 14:36 on Saturday, February 28, 2009
 

thx, it was helpfull :=)








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  reading xml embedded in HTML with JavaScript.
•  how to convert wav file to text file
•  html code running php function
•  Re: NEWBIE in need of help.
•  Converting a Long to Date time
•  How do I pass javascript cart variables to asp email body?
•  How do I pass javascript cart variables to asp email body?
•  Converting 8 byte hex value to datetime value
•  Re: perl \ query


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2009