javascript & HTML cook book 筆記

來源:互聯網
上載者:User

1.javascript 字串周圍可以用引號括起來,單引號和雙引號都可以,但是必須成對。

2.doucment.write()方法可以向文檔中中寫入HTML運算式或javascript代碼

3.Regex匹配:g 模式是否被用於全域

                          i 模式是否區分大小寫

                          m 字串的每個物理行是否被當成字串的開始

4.正則標記

  \b   詞語邊界     /\bto/ 匹配 tomorrow  /to\b/匹配Soweto /\bto\b/匹配 to

  \B   非詞語邊界  /\Bto/匹配stool 和 Soweto   /to\B/匹配stool和tomorrow

  \d   0-9 的數字  /\d\d/ 匹配42

  \D   非數字    /\D\D/ 匹配 to

  \s   單個空白字元  /under\sdog/ 匹配 under dog

   \S  單個非空白字元  /under\Sdog/ 匹配 under-dog

  \w   字母、數字或底線      /1\w/ 匹配 1A

  \W  字母、數字或底線之外的字元  /1\W/ 匹配1%

  .   除分行符號之外的任何字元     /../ 匹配

[...]   括弧內字元組中的任何字元     /J[aeiou]y/匹配Joy

[^...]  否定的字元組         /J[^eiou]y/ 匹配Jay

*     0次或多次          /\d*/ pp "","5","444"

?     0次或1次           /\d?/匹配 “5”,""

+    1次或多次          /\d+/匹配“5”,"444"

{n}   正好n次           /\d{2}/ 匹配 "55"

{n,}    n次或多次          /\d{2,}/匹配“555”

{n,m}     最少n次,最多m次        /\d{2,4}/ 匹配“5555”

^  字串或行的          /^Sally/ 匹配"Sally says..."

$   字串或行的結束        /Sally.$/ 匹配"Hi,Sally."

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.