1

I'm using the Regex functionality in Notepad++ to delete all characters between specific characters. For example I have text file with the following line:

table.column NOT IN ('AB1','CD2')$D$AB1,CD2$X$ 

I would like to locate the text contained within $D$ & $X$ giving me a selection of

$D$AB1,CD2$X$ 

Can anyone give me some pointers on how to achieve this?

Many thanks,

Joe

1 Answer 1

0

With the limited information from you example, I would suggest this:

Find what: (.*?\$D\$).*(\$X\$.*)

Replace with: \1TEST\2

Basically, the find expression consists of two capturing blocks ending and starting around the part you want to replace, and the replace expression reconstructs the line with your replacement.

4
  • Many thanks for the reply - I've tried this and it removes the text preceding the $D$...$X$ block. Ideally I would like only the text between $D$ & $X$ removed Commented Feb 16, 2015 at 15:34
  • @aphrek I thought you wanted to get $D$AB1,CD2$X$. Could you give an example of the desired result? Commented Feb 16, 2015 at 15:46
  • Hi, sorry my explanation wasnt great. I would like to replace text within the $D$ and $X$. first example (replacing existing text with string TEST): table.column NOT IN ('AB1','CD2')$D$AB1,CD2$X$ should return table.column NOT IN ('AB1','CD2')$D$TEST$X$ another example: table.column NOT IN ('CF1','GD2')$D$CF1,GD2$X$ AND table.amount > 0 should return table.column NOT IN ('CF1','GD2')$D$TEST$X$ AND table.amount > 0 Commented Feb 16, 2015 at 16:12
  • @aphrek updated answer according to your last comment Commented Feb 16, 2015 at 16:25

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.