Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

Regex prob (for want of a better subject!)

Last post 07-08-2008, 8:45 PM by misterpea. 5 replies.
Sort Posts: Previous Next
  •  07-08-2008, 3:05 AM 43855

    Regex prob (for want of a better subject!)

    Hi,

    I have some text like:

    some text and more text etc...
    <td></td>
    <td>JMETER0123</td>
    <td>Foo</td>
    <td>Bar</td>
    <td>Baz</td>
    <td>30-May-2008</td>
    <td><a href="/project/userdetails.action?userID=42966">View Details</a></td>
    <td><input type="checkbox" name="selectedUser" value="42966" /></td></tr></tbody></table><span class="pagebanner">12 items found, displaying all items.</span><span class="pagelinks"><strong>1</strong></span>   
    more text and more text etc
     

    Wherever I find the text JMETER followed by a numeric value (JMETER[0-9] ), I want to get the very next value of the userID (or the selectedUser value, whichever is easier because it is the same value). So in this case I want the value "42966", without the quotes. I have found posts on the net addressing this exact problem (see http://regexadvice.com/forums/thread/43794.aspx) but for some reason it doesn't do what it says!

    I currently have: (?s)JMETER[0-9].*?userID=.+?"

    which gives me:

    JMETER0123</td>
    <td>Foo</td>
    <td>Bar</td>
    <td>Baz</td>
    <td>30-May-2008</td>
    <td><a href="/project/userdetails.action?userID=42966">View Details</a></td>
    <td><input type="checkbox" name="selectedUser" value="42966"

    I also tried the exact example in that post mentioned above and it does the same thing.

    I have tested this in The Regex Coach (http://www.weitz.de/regex-coach/) and ultimately want to use this in JMeter's Regular Expression Extractor (http://jakarta.apache.org/jmeter/usermanual/component_reference.html#Regular_Expression_Extractor).

    Can anyone help? That would be great!

    Thanks!

    -pea

  •  07-08-2008, 6:40 AM 43858 in reply to 43855

    Re: Regex prob (for want of a better subject!)

    (?s)JMETER[0-9]+.*?userID=([0-9]+)


    looking for a new regex book?
    Regular Expressions Cookbook
  •  07-08-2008, 7:46 PM 43920 in reply to 43858

    Re: Regex prob (for want of a better subject!)

    Thanks ddrudik!

    Once again, that did not work for me :(

    It gave me back:

    JMETER0123</td>
    <td>Foo</td>
    <td>Bar</td>
    <td>Baz</td>
    <td>30-May-2008</td>
    <td><a href="/project/userdetails.action?userID=42966

    I heard that regex might behave differently in some environments? It did not work in my Regex Coach and also not in JMeter (JMeter is a Java application if that helps?)

  •  07-08-2008, 7:56 PM 43921 in reply to 43920

    Re: Regex prob (for want of a better subject!)

    Look in Match Group #1 - it will contain the value you asked for.

    Susan 

  •  07-08-2008, 8:28 PM 43926 in reply to 43921

    Re: Regex prob (for want of a better subject!)

    Hi Susan,

    Thanks for replying! I'm afraid that didn't work either :'(

    I've uploaded the relevant screenshots to show what I did:

    http://misterpea.googlepages.com/regularExpressionScreenshot.png

    http://misterpea.googlepages.com/parametersWithRequest.png

    I tried group 0, 1, 2. With group #0 I get as mentioned in my last post. With any other group number I get the actual parameter name sent with the request (I.e. "${userID}" without the quotes).

    Any suggestions?

  •  07-08-2008, 8:45 PM 43927 in reply to 43926

    Re: Regex prob (for want of a better subject!)

    GOT IT WORKING!!! Yay!!!

    Thanks Susan, I just missed out on doing something. So I did exactly what you said (as seen in the screenshots) and it worked.

    Thanks heaps!

    - pea

     

View as RSS news feed in XML