Javascript-string Object Regular Match

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.