选择显示字体大小

multiline 属性

 

返回 boolean 值,指出正则表达式使用的 multiline 标志(m)的状态。默认值为 false。只读。

rgexp.multiline

必选项 rgexp 参数为 regexp 对象。

说明

如果正则表达式设置了 multiline 标志,那么 multiline 属性返回 true,否则返回 false。如果创建正则表达式对象时使用了 m 标志,那么 multiline 属性就是 true

如果 multilinefalse,那么 "^" 匹配字符串的开始位置,而 "$" 匹配字符串的结束位置。如果 multlinetrue,那么 "^" 匹配字符串开始位置以及 "\n" 或 "\r" 之后的位置,而 "$" 匹配字符串结束位置以及 "\n" 或 "\r" 之前的位置。

示例

以下示例演示了 multiline 属性的特征。如果将 "m" 传递给下面所示的函数,单词 "while" 将被替换为 "and"。这是因为设置了 multiline 标志且 "while" 出现在换行字符的下一行的开始位置。multiline 标志允许在多行的字符串中进行查找。

本函数返回一个字符串以及一个表,表中显示了允许使用的正则表达式标志(gim)的状态。它还返回经过所有替换操作的字符串。

function regexppropdemo(flag){   if (flag.match(/[^gim]/))          //检查标志的有效性。     return("flag specified is not valid");   var r, re, s                       //声明变量。   var ss = "the man hit the ball with the bat.";   ss += "\nwhile the fielder caught the ball with the glove.";   re = new regexp("^while",flag);    //指定要查找的样式。   r = ss.replace(re, "and");         // "a" 替换 "the"   s = "regular expression property values:\n\n"   s += "global  ignorecase  multiline\n"   if (re.global)                     //测试 global 标志。     s += " true     ";   else     s += "false     ";   if (re.ignorecase)                 //测试 ignorecase 标志。     s += " true  ";   else     s += "false  ";   if (re.multiline)                  //测试 multiline 标志。     s += "     true     ";   else     s += "     false   ";   s += "\n\nthe resulting string is:\n\n" + r;   return(s);                         //返回替换的字符串。}

要求

版本 5.5

请参阅

global 属性 ignorecase 属性 正则表达式语法

应用于:regexp 对象


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons