源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

JS 正则表达式的位置匹配

  • 时间:2021-12-09 01:04 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:JS 正则表达式的位置匹配

[url=http://regexpal.com/]http://regexpal.com/[/url]

上面这个网站可以用于在线检测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(零宽断言)

(?=[i]p[/i]) : A positive lookahead assertion. Require that the following characters match the pattern [i]p[/i], but do not include those characters in the match.

(?![i]p[/i]) : A negative lookahead assertion. Require that the following characters do not match the pattern [i]p[/i]. 对于(?=[i]p[/i])和(?![i]p[/i])的使用举一个例子: 要在url(skins/default/images/index/default.png)中匹配"/default/"中的"default",而不匹配"/default.png"中的"default"? 正则表达式: (?!\/)default(?=\/) 其中(?!\/)表示以"/"开头,(?=\/)表示以"/"结尾
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部