0

I have this regular expression:

'(1|2|6|8|13|14|17|20|42|53)'

This will match the numbers listed. Helpful being that I only want those specific numbers.

However, I want to do a replace on these based on the number. As an example, '1' would become 'STL' while '17' would become 'PHX'

Is there a way I can do this in a single Regular Expression? If not, how might I do this in Notepad++ without doing 10 different search and replace operations?

David Starkey
  • 1,840
  • 3
  • 32
  • 48
  • 6
    Regexes alone can't do that. Use a small script (Perl, Python, whatever you like). – Tim Pietzcker Aug 05 '13 at 18:32
  • 2
    I don't believe you can, a simple find and replace would work just as easily for this situation, since you aren't using your capture group. – abc123 Aug 05 '13 at 18:33
  • 2
    Just do the 10 search and replace operations, record a macro if you need to do it multiple times. It's probably faster than writing a script/plugin. – Robadob Aug 05 '13 at 18:34
  • @Robadob Is there a way to disable the popup that says "X occurrences were replaced"? – David Starkey Aug 05 '13 at 18:39
  • The only way I can see that happening is by spamming the replace button, rather than clicking replace all, but then you may have an issue with knowing when to stop. – Robadob Aug 05 '13 at 18:48
  • 1
    @TimPietzcker More recent versions of Notepad++ can achieve what is wanted. See the answer just added. – AdrianHHH Sep 28 '13 at 08:41
  • See this SO answer for a method with one complex regular expression http://stackoverflow.com/questions/11389466/multiple-word-search-and-replace-in-notepad/16104946#16104946 – AdrianHHH Sep 28 '13 at 08:41

0 Answers0