Search code examples
regexreplacenotepad++

Notepad++ Regex replace Hyphens


I have a HTML and the alt tags are in this format:

alt="something-nice-and-beautiful"

How do I replace all hyphens - with spaces only between the alt tags?


Solution

  • I'm still wrapping my brain around this one. My first inclination is to say use this as the search

    (alt="[^"]*?)\-(.*?")

    and then replace with \1 \2. Each time you run it, it will replace one hyphen with one space, just keep doing Replace All until there are no matches left. I might come up with a more elegant solution if I think about it more but this works.