Click here to Skip to main content
15,074,394 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi guys, I am unable to apply multiline regex here. I want 1349 (selected option value) for select tag

<select name="ctl00$MainContent$map$ucBenefitSheet$ddlPrograms" onchange="javascript:setTimeout(&#39;__doPostBack(\&#39;ctl00$MainContent$map$ucBenefitSheet$ddlPrograms\&#39;,\&#39;\&#39;)&#39;, 0)" id="MainContent_map_ucBenefitSheet_ddlPrograms" style="width:100%;">
                            <option value="-1">Please Select...</option>
                            <option value="1475">GSFS - Secure Drive</option>
                            <option value="1476">Gulf States 100,000 Miles</option>
                            <option value="1477">Gulf States Program</option>
                            <option value="1478">Gulf States Toyota Tire &amp; Wheel</option>
                            <option value="1479">Non- Toyota - Used VSA</option>
                            <option value="1480">Non- Toyota- new VSA</option>
                            <option value="1370">SecureNet Tire &amp; Wheel</option>
                            <option selected="selected" value="1349">Standard Program</option>
                            <option value="1481">TAC Expansion</option>
                            <option value="1368">TCUV Base Warrenty</option>
                            <option value="1482">Toyota - New VSA</option>
                            <option value="1483">Toyota - Used VSA</option>


Can someone help me out in this.. Thanks in advance
ZurdoDev 20-Dec-13 11:58am
What does RegEx have to do with this? What's your question?
Member 10479354 20-Dec-13 13:01pm
Ryan, I am working with JMeter and there I need to pass value '1349' which is selected option value. my regex should find that value on the basis of <select name=ctl00$MainContent$map$ucBenefitSheet$ddlPrograms'. Something like that: <select name="ctl00$MainContent$map$ucBenefitSheet$ddlPrograms" (.*[ \n\t\r\v\s]*.*?) <option selected="selected" value="([0-9]+?">) </option>
ZurdoDev 20-Dec-13 13:09pm
Is there a reason you need to use regex instead of just using javascript to get the value?
Member 10479354 20-Dec-13 15:04pm
finally i'll use java script only using that regex.
ZurdoDev 20-Dec-13 15:28pm
I still don't understand. If all you want is the selected value of a dropdown you don't need to do regex. There are much easier ways.
Member 10479354 20-Dec-13 16:05pm
is it possible to generate a regex for this?
ZurdoDev 20-Dec-13 16:12pm
I'm sure it is. I don't do regex though. I do it the easy way. :)

1 solution[^]

For XML you should use XPath. Have a look at select/option[@selected='selected'] .

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900