String Object Regular Match
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" ><html><head><meta http-equiv="Content-type" Content="text/html; Charset=utf-8 "><title>Insert Title here</title><script type="Text/javascript"> varStr="hell21o worl345d!";varreg=/\d{4,}/;//alert (Reg.test (str)); //alert (Str.match (reg)); //alert (Str.search (reg)); function getcity(){ varObjcity=document.getelementbyid ("City");varObjinfo=document.getelementbyid ("Info");//Number of options varLength=objcity.length; Objinfo.innerhtml="Number of options:"+length+"<br/>";//Get all optionsobjinfo.innerhtml+="Get all options:"; for(varI=0; i<objcity.length;i++) {objinfo.innerhtml+=objcity.options[i].text; }//Gets the currently selected option varIndex=objcity.selectedindex; objinfo.innerhtml+="<br/> currently selected item:"+objcity.options[index].text; objinfo.innerhtml+="<br/> currently selected:"+objcity.value; objinfo.innerhtml+="<br/> currently selected:"+objcity.options[index].value; }//Add City function addcity(){ varObjcity=document.getelementbyid ("City");varOption=document.createelement ("option"); option.text="Wuxi"; Option.value="Wuxi"; Objcity.add (option,NULL); }//Change color function changecolor(){ varObjcolor=document.getelementbyid ("Color"); Document.bgcolor=objcolor.value; }</script></head><body> <input type="button" value="Add" onclick=" Addcity () " /> <br/> <select id="City" onchange="getcity ();" > <option value="0">--City--</option> <option value="nanjing">Nanjing</option> <option value="Shanghai">Shanghai</option> <option value="Beijing">Beijing</option> <option value="Shenzhen">Shenzhen</option> </Select> <div id="Info"></div> <select id="Color" onchange="ChangeColor ();" > <option value="Red">Red</option> <option value="Yellow">Yellow</option> <option value="Blue">Blue</option> <option value="green">Green</option> <option value="Pink">Powder</option> <option value="Gray">Gray</option> <option value="Black">Black</option> <option value="Orange">Orange</option> <option value="Purple">Purple</option> </Select> </body></html>
Javascript-string Object Regular Match