This Domain(Admin5.com) is for Sale:

ignoreCase 属性

时间:2007-12-27  来源:不详  作者:林子

返回 Boolean 值,指出正则表达式使用的 ignoreCase 标志(i) 的状态。默认值为 false。只读。 织梦好,好织梦

rgExp.ignoreCase dedecms.com

必选项 rgExp 参数为 RegExp 对象。 copyright dedecms

说明

假如正则表达式设置了 ignoreCase 标志,那么 ignoreCase 属性返回 true,否则返回 false

copyright dedecms

假如使用了 ignoreCase 标志,那就表明在被查找的字符串中匹配样式的时候查找操作将不区分大小写。

织梦好,好织梦

示例

以下示例演示了 ignoreCase 属性的用法。假如传递 "i" 到下面所示的函数中,那么所有的单词 "the" 将被 "a" 替换,包括最开始位置上的 "The"。这是因为设置了 ignoreCase 标志,搜索操作将不区分大小写。所以在进行匹配的时候 "T" 与 "t" 是等价的。 dedecms.com

此函数返回一个字符串以及一个表,表中显示了与答应使用的正则表达式标志(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  = "while the fielder caught the ball with the glove.";

   re = new RegExp("the",flag);    //指定要查找的样式。

   r = ss.replace(re, "a");        //利用 "a" 替换 "the"   s = "Regular Expression property values:"

   s  = "global  ignoreCase  multiline"

   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  = "The resulting string is:"   r;

   return(s);                      //返回替换的字符串

} 
dedecms.com

要求

版本 5.5 copyright dedecms

请参阅

global 属性 | multiline 属性 | 正则表达式语法 内容来自dedecms

应用于:RegExp 对象 织梦内容管理系统

看完这篇,您有何感觉呢?

上一篇:Infinity 属性   下一篇:global 属性

文章评论

共有位Admini5网友发表了评论 查看完整内容

24小时热门信息