国产探花免费观看_亚洲丰满少妇自慰呻吟_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(?=//)

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


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 茂名市| 开江县| 海南省| 舒城县| 新泰市| 郧西县| 南昌市| 庆阳市| 那曲县| 广德县| 大新县| 宝鸡市| 东丰县| 兴宁市| 出国| 宣威市| 江永县| 巧家县| 绍兴市| 永州市| 北辰区| 腾冲县| 龙游县| 淮南市| 韩城市| 天镇县| 宁国市| 新绛县| 任丘市| 湟中县| 镇康县| 武鸣县| 肥城市| 东丽区| 自贡市| 定远县| 洛扎县| 锡林郭勒盟| 木兰县| 成都市| 黄骅市|