国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Regex > 正文

JS 正則表達式的位置匹配

2020-03-16 21:14:28
字體:
來源:轉載
供稿:網友
JS中正則表達式的位置匹配代碼,國外翻譯的文章。
 
 

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) :

p

 

(?!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(?=//)

其中(?!//)表示以"/"開頭,(?=//)表示以"/"結尾


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 凯里市| 万全县| 靖州| 晋城| 乌鲁木齐市| 曲周县| 长顺县| 宜兰县| 鱼台县| 台湾省| 恭城| 神农架林区| 三穗县| 台南市| 嘉义市| 年辖:市辖区| 阳东县| 新民市| 乌兰浩特市| 武乡县| 万源市| 柏乡县| 新邵县| 峨边| 普兰店市| 大同市| 东阳市| 宜君县| 洛南县| 黔东| 大化| 盐源县| 鄯善县| 长治市| 阆中市| 保亭| 宝丰县| 周宁县| 鄂托克旗| 乐东| 正定县|