Notepad++ – Find and Replace Within a Constant String

notepadregex

Using notepad++ I have the following text.

This little piggy went to market, \textbf{smith1774}
This little \textbf{ben1864} piggy stayed \textbf{mueller2867} home,
This little piggy had roast beef

Now I want to remove the \text{} but keep the text in the middle.

I cant do a simple search and replace in two steps (\text{ + }) as my document contains {} in other positions…..

Best Answer

You can do it following these steps:

  • open find and replace dialog (CTRL+H)
  • make sure "regular expression" box is checked
  • find what:
    \\textbf\{([^}]*)\}
  • replace to:
    $1

You can test is here

Related Question