5

How to find and replace in Notepad++ multiple different characters to corresponding letters at once throughout the text? For example, I have 32 characters that I want to replace. So I have the character like “À”, and I want to replace it with the letter “A”. Next, I have the character like “Æ” and I want to replace it with the letter “Ж” and so on. Generally, I have 32 such characters and each time I need to do the same operation. Is any way to do this at once?

Image demonstrating request

4 Answers 4

5

From notepad >= 6.0 you can replace multiple characters (matches) using something similar to:

search: (Ì)|(Í)|(Î)|(Ï)|(Ð)|(Ñ)
replace: (?1H)(?2O)(?3Π)(?4P)(?5C)(?6T)

Here every character is a captured group and is replaced by the characted in the replace string. Every replace character specifies the index of the group, starting at 1. For instance (?3Π) replaces the group 3 which in this case is the character Î. Î -> Π

You can see more on this answer.

1

Sometimes I have used wReplace from sharktime.com. It works pretty well. You install it and then can indicate as many characters to change as you want to.

I know it isn't a plugin style solution, but it works. Hope this helps!

It is very simple to use. This is a before/after image

1
  • 2
    always good to mention the name of the program in the post so that they don't have to hover their mouse over the link to see what program you mean.
    – barlop
    Jun 16, 2012 at 15:49
0

This previous question provides an answer. Short version is, within Notepad++ with no plugins, it's not possible due to the way Find and Replace works.

I'd look at using sed or similar.

0

Even with Notepad++ 6's new RegEx engine that supports PCRE (source), there's no sane (i.e., with linear complexity) and reliable (i.e., guaranteed to work) approach that will allow you do achieve this in a single Find & Replace, let alone a single Find in Files.

You can, however, achieve this by using Find in Files twice:

  1. Add a substitution matrix to each occurrence of any of the old characters:

    Find what:    ([ÌÍÎÏÐÑ])
    Replace with: ``\1`ÌH`ÍO`ÎΠ`ÏP`ÐC`ÑT``
    Search Mode:  Regular Expression
    

    This transforms fooÌbar into foo``Ì`ÌH`ÍO`ÎΠ`ÏP`ÐC`ÑT``bar, for example.

  2. Replace each old character (and the substitution matrix) with the corresponding new character:

    Find what:    ``(.).*?`\1(.).*?``
    Replace with: \2
    Search Mode:  Regular Expression
    

    This transforms foo``Ì`ÌH`ÍO`ÎΠ`ÏP`ÐC`ÑT``bar into H, for example.

Note that you need to upgrade to Notepad++ 6.0 or higher for this. While the regular expression itself should also work with the old RegEx engine, there's a bug messes up multibyte characters in general.

How it works

    • The character set ([ÌÍÎÏÐÑ]) matches any of those five characters.

      The parentheses turn this into the first subexpression (see next item).

    • \1 symbolizes the match of the first subexpression, i.e., the character we want to replace.

    • All other characters are treated literally.

    • The choice of ` as the delimiter is arbitrary. You can use any other character you want.

    • (.) matches the first character after ``.

      The parentheses turn this into the first subexpression.

    • .*? matches as few characters as possible.

    • `\1 symbolizes ` followed by the match of the first subexpression, i.e., the character we want to replace.

    • (.) matches the first character after the character we want to replace. By our design, this is its replacement character.

      The parentheses turn this into the second subexpression.

    • .*?`` matches as few characters as possible until the final `` is encountered.

For further information on regular expressions, consult:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .