Menu

Using placeholders in NP++ search&replace

Ocetalo
2008-06-10
2012-11-13
  • Ocetalo

    Ocetalo - 2008-06-10

    Greetings

    Can placeholders be used in Notepad++ search&replace dialog? I need to replace all entities in a bunch of 50+ XML DocBook files. I need to find all text between "&" and ";" using a placeholder, something like "&*;" then replace all coincidences by any mark-defined convention, e.g. E*E, but leaving the text between unaffected. How can this be in Notepad++ S&R dialog?

    Thanks in advance. God bless you.

     
    • Fool4UAnyway

      Fool4UAnyway - 2008-06-10

      As long as each occurrence is on a single line, I guess you can use regular expression mode in the Find/Replace dialogs. I prefer to use CTRL+R.

      You have to search for:
      &([^;]+);

      Replace this by:
      E\1E

      Check regex mode.

      This will search for the placeholders including the text in-between and replace it by E + the text in-between + E.

      \1_______ means: the first () grouped expression in the find field

      [^;]_____ means: any character not being a ;
      +________ means: at least one, or more occurences of the preceding expression

      Look for other threads about regular expressions to get more familiar with the subject.

       
      • Ocetalo

        Ocetalo - 2008-06-12

        Thanks a lot. It went just as expected. God bless you.