CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
How many matched?

 



cir
Novice

Jan 28, 2001, 12:28 PM

Post #1 of 3 (1995 views)
How many matched? Can't Post

I really hope this isn't a duplicate post!
How do I know how many matches are in a string?
I'm working on a search engine, and I want to rank the sites by how many times a keyword is in the description.

http://cirw.cjb.net
http://cbible.cjb.net
http://gmail.cjb.net


Jasmine
Administrator

Jan 28, 2001, 3:09 PM

Post #2 of 3 (1993 views)
Re: How many matched? [In reply to] Can't Post

If you think it's been asked before, it probably has Smile. Best bet is to check the Frequently Asked Questions forum first.

How can I count the number of occurrences of a substring within a string?



cir
Novice

Jan 29, 2001, 11:38 AM

Post #3 of 3 (1987 views)
Re: How many matched? [In reply to] Can't Post

" $string = "-9 55 48 -2 23 -76 4 14 -44"; while ($string =~ /-\d+/g) { $count++ } print "There are $count negative numbers in the string";"

Duh, why didn't I think of that! Smile

http://

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives