jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alan Chan" <>
Subject Finding the number of occurences of a given string
Date Thu, 15 Apr 2004 19:52:08 GMT


>From a given long string contained in a variable, I would like to get
the number of occurrences of a certain substring that I also provide.


For example, if I have a user defined variable called ${text} which
contains "example 1 example 2 example 3", and my substring to match is
"example", then the output should be 3.


I was trying to use regular expressions extractor and the regular
expressions function for this but could not figure out how to make it to
output the number of occurrences.


This is the Perl statement that I am trying to convert to something
JMeter can understand:


$text = "example 1 example 2 example 3";

print ($text =~ s/example/example/g);


the output is 3



I also tried using the extended Perl regular expressions, but couldn't
get it to work either.


Any help would be much appreciated.



~Alan Chan




  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message