Regular Expression - Help needed

Discussion in 'Java' started by ragz_82, Aug 4, 2009.

  1. ragz_82

    ragz_82

    Joined:
    Apr 8, 2009
    Messages:
    9
    I am trying to come up with a regex to match the account name from a content. I have been trying this since yesterday with not complete success. Any help is greatly appreciated.

    Following is the content against which comparison is made:

    ******************************************************

    <select name="ctl00$ctl00$MainContent$ContentPlaceHolder2$Calendar3$ddlMonth" id="ctl00_ctl00_MainContent_ContentPlaceHolder2_Calendar3_ddlMonth" class="AANameDropDownBox">
    <option value="January">January</option>

    .......

    <select size="4" name="ctl00$ctl00$MainContent$ContentPlaceHolder2$ListBoxAllAcct" multiple="multiple" id="ctl00_ctl00_MainContent_ContentPlaceHolder2_ListBoxAllAcct" class="AAFlDwldText">
    <option value="114|11470000013|MOUNT CARMEL TR">11470000013 - MOUNT CARMEL TR</option>

    ******************************************************

    Here I need to retrieve the value 114|11470000013|MOUNT CARMEL TR

    I the regex I initially tried is: <option value="(\w+|\w+|[^"]*)">

    This regex is able to retrieve the desired value when tried from a test class. But in the actual scenario as above, the value January is returned. Looks like it is matching the sequence well before the Account value is reached.

    But I am surprised as to how it is ignoring the PIPE '|' symbol used in the regex, which is clearly missing in the value 'January'.

    Please let me know if you need any clarifications.

    Thanks,
    Raghu
     
    ragz_82, Aug 4, 2009
    #1
    1. Advertising

  2. ragz_82

    ragz_82

    Joined:
    Apr 8, 2009
    Messages:
    9
    Following is the regex which worked: <option value="(\w+[|]\w+[|][^"]*)">

    Looks like to enforce the presence of a character we need to enclose it within square brackets '['.

    Thanks for your interest.
     
    ragz_82, Aug 4, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VSK
    Replies:
    2
    Views:
    2,388
  2. David Cho
    Replies:
    4
    Views:
    425
    David Cho
    Feb 15, 2005
  3. Chanchal
    Replies:
    1
    Views:
    502
    NullBock
    Dec 13, 2005
  4. pekka niiranen
    Replies:
    5
    Views:
    561
    Paul McGuire
    Oct 20, 2004
  5. Gianni B.

    regular expression help needed

    Gianni B., Sep 6, 2004, in forum: ASP General
    Replies:
    0
    Views:
    110
    Gianni B.
    Sep 6, 2004
Loading...

Share This Page