I use Notepad++ to search and replace using regular expressions, and I need to replace more than one line with something else each.. Can I do that with one command ?
Example:
"../../../commons/js/site-name.com__file-name.js"
"../dlds/file.css"
or
anytext "../../../commons/js/site-name.com__file-name.js" text
something "../dlds/file.css" anytext
or
<script src="../../../Folder/js/site-name.com__file-name.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="/folder/file.css" />
output should be
"/resources/common.js"
"/resources/common.css"
Given that:
search for ^.+/(filename.js|style.css)"$
Replace with "/resources/$1"
If you want to get any filename not just filename.js or style.css, use this
^.+\/(.+)(?!\/)"$
and use the same replacement.
Find:
\.\..+/([^\.]+\.\w+)
Replace:
/resources/\1
Update:
If you want to just replace filename.js or style.css find:
[\./]{1}.+/(filename.js|style.css)
replace with
/resources/\1
How about:
search for : "(?:\\.\\./)+.*/([^.]+\\.\\w+)"
replace with : "/ressources/$1"
if you want to replace with new.js
or new.css
do:
search for : "(?:\\.\\./)+.*/[^.]+(\\.\\w+)"
replace with : "/ressources/new$1"
for match also urls that begin with /
:
search for : "(?:(?:\\.\\./)+.*?)?/([^.]+\\.\\w+)"
replace with : "/ressources/new$1"
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.