Solved

extract value and name from the SELECT control

Posted on 2009-05-12
3
154 Views
Last Modified: 2013-11-19
Hello All,

I have got bunch of HMTL SELECT control data and I have to extra id and values and delete everything from it.

I know I can cut and paste IDs and Values out from the attached, but I wonder If someone can advise the easy and quick way to do this as I have got few more SELECT tags data to use.

All I want from the below is the values and names , ex:

004 Afghanistan
008 Albania
  .....


Please can someone help?

thanks
s

<select id="bcountry" name="bcountry" onfocus="setActive1(this)" onblur="setOut(this)">
		<option value="004">Afghanistan</option> 
		<option value="008">Albania</option> 
		<option value="012">Algeria</option> 
		<option value="016">American Samoa</option>  
		<option value="020">Andorra</option>  
		<option value="024">Angola</option>  
		<option value="660">Anguilla</option>  
		<option value="010">Antarctica</option>  
		<option value="028">Antigua And Barbuda</option>   
		<option value="032">Argentina</option>  
		<option value="051">Armenia</option>  
		<option value="533">Aruba</option>  
		<option value="036">Australia</option>  
		<option value="040">Austria</option>  
		<option value="031">Azerbaijan</option>  
		<option value="044">Bahamas</option>  
		<option value="048">Bahrain</option>  
		<option value="050">Bangladesh</option>  
		<option value="052">Barbados</option>  
		<option value="112">Belarus</option>  
		<option value="056">Belgium</option>  
		<option value="084">Belize</option>  
		<option value="204">Benin</option>  
		<option value="060">Bermuda</option>  
		<option value="064">Bhutan</option>  
		<option value="068">Bolivia</option>  
		<option value="070">Bosnia and Herzegovina</option>  
		<option value="072">Botswana</option>  
		<option value="074">Bouvet Island</option>  
		<option value="076">Brazil</option>  
		<option value="086">British Indian Ocean Territory</option>  
		<option value="096">Brunei Darussalam</option>  
		<option value="100">Bulgaria</option>  
		<option value="854">Burkina Faso</option>   
		<option value="108">Burundi</option>  
		<option value="116">Cambodia</option>  
		<option value="120">Cameroon</option>  
		<option value="124">Canada</option>  
		<option value="132">Cape Verde</option>  
		<option value="136">Cayman Islands</option>  
		<option value="140">Central African Republic</option>  
		<option value="148">Chad</option>  
		<option value="152">Chile</option>  
		<option value="156">China</option>  
		<option value="162">Christmas Island</option>  
		<option value="166">Cocos (Keeling) Islands</option>  
		<option value="170">Colombia</option>  
		<option value="174">Comoros</option>  
		<option value="178">Congo</option>  
		<option value="180">Congo, Democractic Republic of the</option>  
		<option value="184">Cook Islands</option>  
		<option value="188">Costa Rica</option>  
		<option value="384">Cote D'Ivoire (Ivory Coast)</option>  
		<option value="191">Croatia (Hrvatska)</option>  
		<option value="192">Cuba</option>  
		<option value="196">Cyprus</option>  
		<option value="203">Czech Republic</option>  
		<option value="208">Denmark</option>  
		<option value="262">Djibouti</option>  
		<option value="212">Dominica</option>  
		<option value="214">Dominican Republic</option>  
		<option value="626">East Timor</option>  
		<option value="218">Ecuador</option>  
		<option value="818">Egypt</option>  
		<option value="222">El Salvador</option>  
		<option value="226">Equatorial Guinea</option>  
		<option value="232">Eritrea</option>  
		<option value="233">Estonia</option>  
		<option value="231">Ethiopia</option>  
		<option value="238">Falkland Islands (Islas Malvinas)</option>  
		<option value="234">Faroe Islands</option>   
		<option value="242">Fiji</option>   
		<option value="246">Finland</option>   
		<option value="250">France</option>   
		<option value="254">French Guiana</option>   
		<option value="258">French Polynesia</option>   
		<option value="260">French Southern Territories</option>   
		<option value="266">Gabon</option>   
		<option value="270">Gambia</option>   
		<option value="268">Georgia</option>   
		<option value="276">Germany</option> 
		<option value="288">Ghana</option> 
		<option value="292">Gibraltar</option> 
		<option value="300">Greece</option> 
		<option value="304">Greenland</option> 
		<option value="308">Grenada</option> 
		<option value="312">Guadeloupe</option> 
		<option value="316">Guam</option> 
		<option value="320">Guatemala</option> 
		<option value="324">Guinea</option> 
		<option value="624">Guinea-Bissau</option> 
		<option value="328">Guyana</option> 
		<option value="332">Haiti</option> 
		<option value="334">Heard and McDonald Islands</option> 
		<option value="336">Holy See (Vatican City State)</option> 
		<option value="340">Honduras</option> 
		<option value="344">Hong Kong</option> 
		<option value="348">Hungary</option> 
		<option value="352">Iceland</option> 
		<option value="356">India</option> 
		<option value="360">Indonesia</option> 
		<option value="364">Iran, Islamic Republic Of</option> 
		<option value="368">Iraq</option> 
		<option value="372">Ireland</option> 
		<option value="376">Israel</option> 
		<option value="380">Italy</option> 
		<option value="388">Jamaica</option> 
		<option value="392">Japan</option> 
		<option value="400">Jordan</option> 
		<option value="398">Kazakhstan</option> 
		<option value="404">Kenya</option> 
		<option value="296">Kiribati</option> 
		<option value="408">Korea, Democratic People's Republic</option> 
		<option value="410">Korea, Republic Of</option>  
		<option value="414">Kuwait</option> 
		<option value="417">Kyrgyzstan</option> 
		<option value="418">Laos, People's Demcratic Republic</option> 
		<option value="428">Latvia</option> 
		<option value="422">Lebanon</option> 
		<option value="426">Lesotho</option> 
		<option value="430">Liberia</option> 
		<option value="434">Libyan Arab Jamahiriya</option> 
		<option value="438">Liechtenstein</option> 
		<option value="440">Lithuania</option> 
		<option value="442">Luxembourg</option> 
		<option value="446">Macao</option> 
		<option value="807">Macedonia, Former Yugoslav Republic of</option>  
		<option value="450">Madagascar</option> 
		<option value="454">Malawi</option> 
		<option value="458">Malaysia</option> 
		<option value="462">Maldives</option> 
		<option value="466">Mali</option> 
		<option value="470">Malta</option> 
		<option value="584">Marshall Islands</option> 
		<option value="474">Martinique</option> 
		<option value="478">Mauritania</option> 
		<option value="480">Mauritius</option> 
		<option value="175">Mayotte</option> 
		<option value="484">Mexico</option> 
		<option value="583">Micronesia, Frederated States Of</option> 
		<option value="498">Moldova, Rebulic Of</option> 
		<option value="492">Monaco</option> 
		<option value="496">Mongolia</option> 
		<option value="500">Montserrat</option> 
		<option value="504">Morocco</option> 
		<option value="508">Mozambique</option> 
		<option value="104">Myanmar</option> 
		<option value="516">Namibia</option> 
		<option value="520">Nauru</option> 
		<option value="524">Nepal</option> 
		<option value="528">Netherlands</option> 
		<option value="530">Netherlands Antilles</option> 
		<option value="540">New Caledonia</option> 
		<option value="554">New Zealand</option> 
		<option value="558">Nicaragua</option> 
		<option value="562">Niger</option> 
		<option value="566">Nigeria</option> 
		<option value="570">Niue</option> 
		<option value="574">Norfolk Island</option> 
		<option value="580">Northern Mariana Islands</option> 
		<option value="578">Norway</option> 
		<option value="512">Oman</option> 
		<option value="586">Pakistan</option> 
		<option value="585">Palau</option> 
		<option value="275">Palestinian Territory, Occupied</option> 
		<option value="591">Panama</option> 
		<option value="598">Papua New Guinea</option>  
		<option value="600">Paraguay</option> 
		<option value="604">Peru</option> 
		<option value="608">Philippines</option> 
		<option value="612">Pitcairn</option> 
		<option value="616">Poland</option> 
		<option value="620">Portugal</option> 
		<option value="630">Puerto Rico</option> 
		<option value="634">Qatar</option> 
		<option value="638">Reunion</option> 
		<option value="642">Romania</option> 
		<option value="643">Russian Federation</option> 
		<option value="646">Rwanda</option> 
		<option value="654">Saint Helena</option> 
		<option value="659">Saint Kitts And Nevis</option> 
		<option value="662">Saint Lucia</option> 
		<option value="666">Saint Pierre and Miquelon</option> 
		<option value="670">Saint Vincent And The Grenadines</option> 
		<option value="882">Samoa</option> 
		<option value="674">San Marino</option> 
		<option value="678">Sao Tome and Principe</option> 
		<option value="682">Saudi Arabia</option> 
		<option value="686">Senegal</option> 
		<option value="690">Seychelles</option> 
		<option value="694">Sierra Leone</option> 
		<option value="702">Singapore</option> 
		<option value="703">Slovakia</option> 
		<option value="705">Slovenia</option> 
		<option value="090">Solomon Islands</option> 
		<option value="706">Somalia</option> 
		<option value="710">South Africa</option> 
		<option value="239">South Georgia And The South Sandwich Islands</option> 
		<option value="724">Spain</option> 
		<option value="144">Sri Lanka</option> 
		<option value="736">Sudan</option> 
		<option value="740">Suriname</option> 
		<option value="744">Svalbard And Jan Mayen</option> 
		<option value="748">Swaziland</option> 
		<option value="752">Sweden</option> 
		<option value="756">Switzerland</option> 
		<option value="760">Syrian Arab Republic</option> 
		<option value="158">Taiwan</option> 
		<option value="762">Tajikistan</option> 
		<option value="834">Tanzania, United Republic Of</option> 
		<option value="764">Thailand</option> 
		<option value="768">Togo</option> 
		<option value="772">Tokelau</option> 
		<option value="776">Tonga</option> 
		<option value="780">Trinidad And Tobago</option> 
		<option value="788">Tunisia</option> 
		<option value="792">Turkey</option> 
		<option value="795">Turkmenistan</option> 
		<option value="796">Turks And Caicos Islands</option> 
		<option value="798">Tuvalu</option> 
		<option value="800">Uganda</option> 
		<option value="804">Ukraine</option> 
		<option value="784">United Arab Emirates</option> 
		<option value="826" selected="selected" >United Kingdom</option> 
		<option value="840">United States</option> 
		<option value="581">United States Minor Outlying Islands</option> 
		<option value="858">Uruguay</option> 
		<option value="860">Uzbekistan</option> 
		<option value="548">Vanuatu</option> 
		<option value="862">Venezuela</option> 
		<option value="704">Vietnam</option> 
		<option value="092">Virgin Islands, British</option> 
		<option value="850">Virgin Islands, US</option> 
		<option value="876">Wallis And Futuna</option> 
		<option value="732">Western Sahara</option> 
		<option value="887">Yemen</option> 
		<option value="891">Yugoslavia</option> 
		<option value="894">Zambia</option> 
		<option value="716">Zimbabwe</option>

Open in new window

0
Comment
Question by:newbie27
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 39

Accepted Solution

by:
abel earned 500 total points
ID: 24363747
Depending on the tools you have at hand, I would choose a simple search/replace. I'll suggest the most straightforward one here, because I know it will work in any editor, even Notepad, but I'm sure you have something more fancy, so we can also dig up a regular expression for you if you like.

Straightforward:
(1) search: <option value="
replace: (nothing)

(2) search: ">
replace: (space)

(3) search: </option>
replace: (nothing)

in the above, "(nothing)" should be replaced with, indeed, nothing and "(space)" should be replaced with a space. You can do this in one go with regular expressions:

regex search: ^\s*<option value="([^"]+">([^<]+)</option>
regex replace: $1 $2

depending on your regex flavor (what editor are you using?) you may need to replace the $1 and $2 for \1 and \2, and the (..) for \{..\} or \(..\).

-- Abel --
0
 
LVL 8

Author Comment

by:newbie27
ID: 24364330
hi abel

thanks for your input, much appreciated.

will use your reg expressions, very handy thanks.

however, please can you advise if i want to store them into 2 columns in excel file after find/replace...how  would i go about doing?

thanks
s
0
 
LVL 39

Expert Comment

by:abel
ID: 24367671
I would use the approach of using CSV for that. In other words, instead of putting a space in the replace expression, just but a comma in there. When you copy / paste that into excel, it will automatically recognize it. You can also save it as *.csv and double click it to open it. A wizard will open which will default to two columns.

Tx for the grade and the pts :)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question