Date: 2004-12-08T11:01:34
   Editor: SebastianBazley <[EMAIL PROTECTED]>
   Wiki: Apache JMeter Wiki
   Page: RegularExpressions
   URL: http://wiki.apache.org/jakarta-jmeter/RegularExpressions

   Added multiple group example

Change Log:

------------------------------------------------------------------------------
@@ -35,6 +35,8 @@
 
 === Examples ===
 
+==== Extract single string ====
+
 Suppose you want to match the following portion of a web-page: {{{name="file" 
value="readme.txt"}}} and you want to extract {{{readme.txt}}}.
 
 A suitable reqular expression would be:
@@ -49,3 +51,28 @@
 
 Note: without the {{{?}}}, the {{{.+}}} would continue past the first {{{"}}} 
until it found the last possible {{{"}}} - probably not what was intended.
  
+==== Extract multiple strings ====
+
+Suppose you want to match the following portion of a web-page: 
{{{name="file.name" value="readme.txt"}}} and you want to extract 
{{{file.name}}} and {{{readme.txt}}}.
+
+A suitable reqular expression would be:
+
+name="{{{(.+?)}}}" value="{{{(.+?)}}}"
+
+This would create 2 groups, which could be used in the JMeter Regular 
Expression Extractor template as $1$ and $2$.
+
+The JMeter Regex Extractor saves the values of the groups in additional 
variables. 
+
+For example, assume:
+ * Reference Name: is MYREF
+ * Regex: name="{{{(.+?)}}}" value="{{{(.+?)}}}"
+ * Template: $1$$2$
+
+The following variables would be set:
+
+ * MYREF: file.namereadme.txt
+ * MYREF_g0: name="file.name" value="readme.txt"
+ * MYREF_g1: file.name
+ * MYREF_g2: readme.txt
+
+These variables can be referred to later on in the JMeter test plan, as 
${MYREF}, ${MYREF_g1} etc

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to