Regular Expression - Help needed

Joined
Apr 8, 2009
Messages
9
Reaction score
0
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
 
Joined
Apr 8, 2009
Messages
9
Reaction score
0
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top