Search code examples
searchnotepad++mode

replace multiple values with regular Expression (Extended search mode) in notepad++


i was searching for some tool to help me to replace tag with multiple values, but i quickly realized that notepad++ which i use can help me, especially with what they call it "regular Expression"

well i tried to search and learn that, but it seems i have no time, so what i need you to help me with

i need to replace many tag with multiple values

<a href="wordpress_38546.html">Home</a>
<a href="reviews/">Reviews</a>
<a href="news/">News</a>
<a href="features/">Featured</a></li>
<a href="blog/">Blog</a>
<a href="contacts/">Contacts</a>

to make it

<a href="#">Home</a>
<a href="#">Reviews</a>
<a href="#">News</a>
<a href="#">Featured</a></li>
<a href="#">Blog</a>
<a href="#">Contacts</a>

The problem was i have multiple <a> tag with multiple href="" values also inside many of the <a> tag there is class= and id= that i wanna keep it

the solutions: Find what :(<a href="+.*)( ) Replace with :<a href="#"

solutions Explanation the first parentheses () allow us to access whatever is inside the parentheses inside it i made it seach for <a href=" and i wanted to make to keep select what ever after the <a href=" which is the url i wanna remove, so i put +.* to contue selecting everything after href=" once i select the url, i wanna stop selecting so i put space in the second parentheses to be like that ( ) to make it stop selecting after the space that separates the elements is selected

in most causes the <a href="url"> tag that has class or id or both, there's space between the the last Quotation mark that belongs to the href element and the 'class' element or any other element written after

Cheers!


Solution

    • Find what: href=\".+\"

    • Replace with: href="#"

    This works for the sample you have provided. It might not work if the real text is more complex.