I have project on Asp.NET Web Forms.
I need to update hrefs on Views. This hrefs is for Downloading, so on click user are able to save document, in my case .pdf
files. So i need to change href-Links just for target pdf-files
Example : Now href is in next format:
href="/about/news/downloads/Ingram%20Announcement_5.31.07.pdf"
What is needed : Add
<%=MyProject.Core.Common.PublisherConfigurationManager.Content%>
instead of first /
in href link (possible href link hasn't /
as first symbol).
Expected result is:
href="<%=MyProject.Core.Common.PublisherConfigurationManager.Content%>
about/news/downloads/Ingram%20Announcement_5.31.07.pdf"
How can i make this update using Ctrl + Shift + F and Regex?
Work in VS 2013
This will match any href ending in ".pdf".
Regex: href\\=\\"/?([^"]+\\.pdf)\\"
.
Note this will match the optional /
but not capture it. Then it finds at least 1 character which is not a quote to close the href
and ends with .pdf"
. The path without the leading /
and filename are then stored in match position $1
Replacement: href="<%=MyProject.Core.Common.PublisherConfigurationManager.Content%>$1"
If you want to match other extensions in addition to pdfs, you can just add an OR clause |
to the regex. For example href\\=\\"/?([^"]+\\.(pdf|jpg))\\"
will match pdfs and jpgs. The replacement does not need to change
按ctrl + h并在搜索词中输入href="/
在替换词中输入href="/
href="<%=MyProject.Core.Common.PublisherConfigurationManager.Content%>
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.