How about this . $str = 'syhk...yes...uhg;ka=...yes...yiealg.....yes.......ghe;a...yes...'; $count = $str; $count = $count =~ s/yes//g; print "$count\n"
-----Original Message----- From: zhihua li [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 24, 2006 10:05 AM To: beginners@perl.org Subject: count the characters between the matches hi netters, I'm curious if there's any smart code to calculate the "distance" between the matches in a text. Suppose I have a text like this: syhk...yes...uhg;ka=...yes...yiealg.....yes.......ghe;a...yes... Apparently it has multiple words of "yes". I'd like to know how many characters there are between the first and the last "yes". The way I now come up with to do this is to use substitution to "mark" the first and the last match, then use a counting loop to calculate the characters......rather straightforward and stupid method. Anyone has a better idea about that? Thanks a lot! _________________________________________________________________ 免费下载 MSN Explorer: http://explorer.msn.com/lccn -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>