JavaScript正則表達式之multiline屬性的應用
更新時間:2015年06月16日 09:57:39 投稿:goldensun
這篇文章主要介紹了JavaScript正則表達式之multiline屬性的應用,是JS學習進階中的重要知識,需要的朋友可以參考下
多行正則表達式是對象的只讀布爾屬性。它指定是否一個特定的正則表達式進行多行匹配,即,不管是否使用“m”屬性創(chuàng)建。
語法
RegExpObject.multiline
下面是參數(shù)的詳細信息:
- NA
返回值:
- 如果“m”修改被設置返回“TRUE”,否則返回“FALSE”。
例子:
<html> <head> <title>JavaScript RegExp multiline Property</title> </head> <body> <script type="text/javascript"> var re = new RegExp( "string" ); if ( re.multiline ){ document.write("Test1-multiline property is set"); }else{ document.write("Test1-multiline property is not set"); } re = new RegExp( "string", "m" ); if ( re.multiline ){ document.write("<br/>Test2-multiline property is set"); }else{ document.write("<br/>Test2-multiline property is not set"); } </script> </body> </html>
這將產(chǎn)生以下結果:
Test1 - multiline property is not set Test2 - multiline property is set
相關文章
基于js 字符串indexof與search方法的區(qū)別(詳解)
下面小編就為大家分享一篇基于js 字符串indexof與search方法的區(qū)別介紹,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2017-12-12window.close(); 關閉瀏覽器窗口js代碼的總結介紹
下面小編就為大家?guī)硪黄獁indow.close(); 關閉瀏覽器窗口js代碼的總結介紹。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-07-07