Menu

Using a backslash in Replacement Text in NP++

2007-08-09
2012-11-13
  • Nobody/Anonymous

    Hi,

    <b>I posted this a few days ago, but no one has responded at all -- is this because no one is listening, or does nobody know the answer to my simple question? All I want to do is use regular expression matching to insert text which includes a backslash, like "\abc" or "\xyz".</b> Here is the post again:

    I'm relatively new to Notepad++, and am having trouble getting a fairly standard regular expression working.
    I'm working in LaTeX, and want to using Find/Replace (either CTRL-H or CTRL-R) to insert some LaTeX macros into my document.

    Eg. I want to put "\abc" at the beginning of each line in the selected text.

    Normally (in Perl, PHP, etc) I would just use "\\abc" as the replacement text, so that "\\" (double backslash) would give me a single backslash in the document, followed by abc (the desired result). Notepad++, however, has the annoying habit of grouping the second backslash with the "a", not the first backslash!

    The only solution I have found so far is to do it in two steps -- replace with plain "abc" with regular expressions turned on, then replace all "abc"s with "\abc"s with regular expressions turned off.

    Surely it is possible in one step?

    Thanks,
    Simon

     
    • pshute

      pshute - 2007-08-15

      According to http://notepad-plus.sourceforge.net/uk/regExpList.php, \\ should work.  It wouldn't surprise me if it didn't though.

       
MongoDB Logo MongoDB