在正则表达式中包含其他模式时排除某些单词

时间:2017-04-13 22:04:30

标签: regex swift

我有这个字符串:

<a href="..">..</a></td><a href="Example.pdf">Example.pdf</a>

我想获得所有链接,我使用这个正则表达式:

href=\"([^/]*?)\"

但是,我希望正则表达式忽略这个特定的字符串:

..

如何修改正则表达式以实现此排除?

1 个答案:

答案 0 :(得分:0)

基于否定前瞻的这个应该有效:function displayImage(myObj) { /* myObj is the thumbnail img object */ objParent = myObj.parentElement objImage = objParent.getElementsByClassName("fullImage")[0]; /* Remove the classname so the Div doesn't use display: flex. */ objParent.className = ""; /* Display the image */ objImage.attributes.style.value = "display:block" /* Hide the thumbnail */ myObj.attributes.style.value = "display:none" } function displayThumbnail(myObj) { /* myObj is the full img object */ objParent = myObj.parentElement objThumbnail = objParent.getElementsByClassName("thumb")[0]; /* Add the classname so the Div uses display: flex. */ objParent.className = "clearfix"; /* Display the thumbnail */ objThumbnail.attributes.style.value = "display:block" /* Hide the image */ myObj.attributes.style.value = "display:none" }

使用第1组提取每场比赛的链接

Demo