Search code examples
regexnotepad++textpad

Regular expressions to replace


I need to replace a bunch of lines for SQL queries

The format is like

"xyzabcd > hdsd + 5 and",
"xzbcd_TTM_dfdfd > hdsd + 20 and",
"x_TTM_dfsddsdsdfd > hdsd + 20 and"

I need to find the keyword TTM and add a "(" at the beginning and " or some condition)" in the end but before the word "and"

So the line

"xzbcd_TTM_dfdfd > hdsd + 20 and",

becomes

"(xzbcd_TTM_dfdfd > hdsd + 20 or some condition) and

I am trying to do it in Textpad but I can also use Notepad++. Thanks a lot in advance.


Solution

  • For Notepad++ and for TextPad you can use

    Search:

    "(.+)\sand",*
    

    Replace:

    "\(\1 OR some condition\) AND