适用于
等文字Save Favorites & Share expressions with friends or the Community.
A full Reference & Help is available in the Library, or watch the video Tutorial.
expressions can start some lines though eventuallys
abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
http://regexr.com/foo.html?q=bar
https://mediatemple.net
mediatemple.net
我想选择长度为11位的单词。
我可以用
/\b[a-zA-Z]{11}\b/g
但它也匹配网址
https://mediatemple.net
mediatemple.net
我该如何避免?我使用\ b而不是在行的开头和结尾匹配的空格
答案 0 :(得分:1)
通过使用否定前瞻,您可以排除在其后面有.something
的单词,这将排除任何网址而不会触及句子末尾的单词(即,如果空格位于点后面或新队)。
/\b[a-zA-Z]{11}\b(?!\.[^\s]+)/g
答案 1 :(得分:0)
您可以使用negative look behind expression确保您的匹配前面没有“://”。
答案 2 :(得分:0)