JS 正則表達(dá)式的位置匹配
http://regexpal.com/
上面這個(gè)網(wǎng)站可以用于在線檢測(cè)JS的正則表達(dá)式語(yǔ)法
除了熟知的幾個(gè)固定字符表示位置:
^ : 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.
還有的就是使用正則表達(dá)式來(lái)確定要匹配的位置,也叫做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.
對(duì)于(?=p)和(?!p)的使用舉一個(gè)例子:
要在url(skins/default/images/index/default.png)中匹配"/default/"中的"default",而不匹配"/default.png"中的"default"?
正則表達(dá)式: (?!\/)default(?=\/)
其中(?!\/)表示以"/"開頭,(?=\/)表示以"/"結(jié)尾
- 正則表達(dá)式教程之重復(fù)匹配詳解
- 正則表達(dá)式教程之匹配一組字符詳解
- 正則表達(dá)式教程之匹配單個(gè)字符詳解
- javascript正則表達(dá)式模糊匹配IP地址功能示例
- js正則表達(dá)式最長(zhǎng)匹配(貪婪匹配)和最短匹配(懶惰匹配)用法分析
- Java 正則表達(dá)式匹配模式(貪婪型、勉強(qiáng)型、占有型)
- 正則表達(dá)式惰性匹配模式(?)
- 正則表達(dá)式匹配IP的表達(dá)式(推薦)
- js正則表達(dá)式惰性匹配和貪婪匹配用法分析
- 正則表達(dá)式匹配任意字符(包括換行符)的寫法
- 正則表達(dá)式匹配不包含某些字符串的技巧
- 正則表達(dá)式教程之位置匹配詳解
相關(guān)文章
正則表達(dá)式在IOS中的應(yīng)用及IOS中三種正則表達(dá)式的使用與比較
本篇文章給大家介紹正則表達(dá)式在IOS中應(yīng)用以及IOS中三種正則表達(dá)式式的使用與比較,感興趣的朋友跟著小編一起來(lái)學(xué)習(xí)學(xué)習(xí)吧2015-09-09