JS 正则表达式的位置匹配

所属分类: 网络编程 / 正则表达式 阅读数: 1001
收藏 0 赞 0 分享

http://regexpal.com/

上面这个网站可以用于在线检测JS的正则表达式语法

除了熟知的几个固定字符表示位置:

^ : Match the beginning of the string and, in multiline searches, the beginning of a line.

$ : Match the end of the string and, in multiline searches, the end of a line.

\b: 

Match a word boundary. That is, match the position between a \w character and a \W character or between a \w character and the beginning or end of a string. (Note, however, that [\b] matches backspace.)

\B: Match a position that is not a word boundary.

还有的就是使用正则表达式来确定要匹配的位置,也叫做Zero-Width Test(零宽断言)

(?=p) :

A positive lookahead assertion. Require that the following characters match the pattern p, but do not include those characters in the match.

(?!p) :

A negative lookahead assertion. Require that the following characters do not match the pattern p.

对于(?=p)和(?!p)的使用举一个例子:

要在url(skins/default/images/index/default.png)中匹配"/default/"中的"default",而不匹配"/default.png"中的"default"?

正则表达式: (?!\/)default(?=\/)

其中(?!\/)表示以"/"开头,(?=\/)表示以"/"结尾

更多精彩内容其他人还在看

能说明一下GETROWS的用法吗?

能说明一下GETROWS的用法吗?
收藏 0 赞 0 分享

用正则表达式过滤html代码

用正则表达式过滤html代码
收藏 0 赞 0 分享

ubb js

ubb js
收藏 0 赞 0 分享

正则表达式在javascript中的几个实例

正则表达式在javascript中的几个实例
收藏 0 赞 0 分享

简单的Html转换UBB的程序

简单的Html转换UBB的程序
收藏 0 赞 0 分享

求个简单正则

求个简单正则
收藏 0 赞 0 分享

JScript中正则表达式用法详解

JScript中正则表达式用法详解
收藏 0 赞 0 分享

取图片路径的正则

取图片路径的正则
收藏 0 赞 0 分享

文本框输入限制 [大全]

文本框输入限制 [大全]
收藏 0 赞 0 分享

UBB代码在论坛中的应用

UBB代码在论坛中的应用
收藏 0 赞 0 分享
查看更多