Search code examples
regexreplacenotepad++

Notepad++ Removing spaces between certain words


I'm having an issue using Notepad++ and trying to remove the two spaces in between the ID's on the document.

EX:

ID = 10103
ID = 10104
ID = 61016

I'm trying to remove ONLY the two spaces between ID and the number. So 'ID = 10103' turns into 'ID=10103' for example. The document has a few thousand of these ID's. Is there some way to mass replace the entire document so the spaces are only the two spaces are removed from the 'ID = _' lines?


Solution

  • I would just directly match the ID = num expressions:

    Find:    \bID = (\d+)\b
    Replace: ID=$1
    

    Demo

    Note that if you are not sure whether there would be whitespace on both sides of the = sign, you could use \bID\s*=\s*(\d+)\b. However, this would match every ID line, even those which are already in the correct format.