Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a recurring word that pops up everywhere in a page of my that is right built into an HTML page. And I want to delete this word and this word only everywhere by using Regex in Notepad++.

The problem is, that the word is also part of another word, and when I try to delete it, the other word is partially deleted as well where the two letters are matched.

Here's an example:

<div>
<p>No November</p>
</div>

As you can see by my example I need to find a way to not delete November, but only the word No. Please state how I can do this.

share|improve this question

migrated from stackoverflow.com Oct 25 '12 at 17:33

This question came from our site for professional and enthusiast programmers.

    
search for 'No '.. add the space after 'No' and 'November' will not be touched.. for complex regex i actually use Dreamweaver.. it handles regex very well and it can also find and replace blocks of code rather than a line with notepad++. –  McMastermind Oct 25 '12 at 15:22
    
I'm on Linux, so I can't use notepad++ right now. Can you check if \<No\> works? \< and \> should find the beginning and the end of a word. blog.creativeitp.com/posts-and-articles/editors/… –  Simone-Cu Oct 25 '12 at 15:26

3 Answers 3

You can type this into the replace box

Find what: (?<![a-zA-Z])[Nn][Oo](?![a-zA-Z])
Replace with:                                     //blank

With your example, it would look like this:

<div>
<p> November</p>
</div>

If you want spaces before or after to get removed as well, you could use this:

Find what: ( |(?<![a-zA-Z]))[Nn][Oo]( |(?![a-zA-Z]))
Replace with:                                     //blank

With your example, it would look like this:

<div>
<p>November</p>
</div>
share|improve this answer

try with js

var str = 'No November';
str = str.replace(/\[No\]/g,'');
share|improve this answer

Try a regular expression with \b placed before and after the search term:

So instead of No, search for \bNo\b. This should only find instances where No does not have anything before and after it, such as in 'November'.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.