python學習day——18

來源:互聯網
上載者:User

標籤:images   asd   正則表達   分享   也會   return   col   image   es2017   

JavaScript補充

 JavaScript正則

test   - 判斷字串是否符合規定的正則rep = /\d+/;rep.test("asdfoiklfasdf89asdfasdf")# truerep = /^\d+$/;//加上^(首)$(尾)就必須所有的字串都符合規定的正則rep.test("asdfoiklfasdf89asdfasdf")# falseexec   - 擷取匹配的資料rep = /\d+/;str = "wangshen_67_houyafa_20"rep.exec(str)//將規定的正則取出來,預設只能取出一個# ["67"]JavaScript is more fun than Java or JavaBeans!var pattern = /\bJava(\w*)\b/;//用()括起來會將匹配(\w*)的欄位也輸出# ["JavaScript", "Script"]JavaScript is more fun than Java or JavaBeans!var pattern = /\bJava\w*\b/g;//g 全域匹配,匹配所有相關的# ["JavaScript"]# ["Java"]# ["JavaBeans"]# nullJavaScript is more fun than Java or JavaBeans!var pattern = /\bJava(\w*)\b/g;//加()同理# ["JavaScript",‘Script‘]# ["Java", ""]# ["JavaBeans", "Beans"]# null
JS正則匹配時本身就是支援多行,此處多行匹配只是影響Regex^和$,m模式也會使用^$來匹配換行的內容) var pattern = /^Java\w*/gm; var text = "JavaScript is more fun than \n JavaEE or JavaBeans!"; result = pattern.exec(text) result = pattern.exec(text) result = pattern.exec(text)
     # ["JavaScript"]
     # ["Java"]
     # ["JavaBeans"]

登入註冊驗證<a herf=... onclick=func()>123</a>  #綁定的時間先執行,如果返回false則阻止<a>標籤的事件發生

預設事件先執行:checkbox自訂先執行asubmit...<form><input type=‘type‘ /><input type=‘password‘ /><input type=‘submit‘ /></form>$(‘:submit‘).click(function(){    //判斷填入是否滿足要求的模型$(‘:text,:password‘).each(function(){...return false;})return false;})   input,checbox

  

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  

 

python學習day——18

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.