Search & replace with wildcards and variable length strings in Notepad++

1

I am trying to edit a series of strings in Notepad++ using search & replace. What I'd like to do is to search for a particular piece of HTML code, then delete a portion of it. The challenging part is that one word in the code segment varies.

For example, I'd like to find every instance of this:

/arama.php?shoes=bile 

(where "shoes" could be any word of varying length - sandals, boots, slippers, flipflops, etc.)

and replace it with just

/shoes=bile 

(where "shoes" is whatever the original word in that position of the string is).

Is this possible? Any ideas how?

Scoop

Posted 2011-12-15T19:39:40.720

Reputation: 11

2I thought np++ could handle full regex... – ratchet freak – 2011-12-15T20:03:38.767

Learn searching with regular expressions, aka regex. – mtone – 2011-12-15T20:19:09.003

Any good ideas of where to go to learn more? I tried using an asterisk (*) as a wildcard, but that doesn't work. I've used '?' in other programs, but when the string is of variable length, that doesn't work. I've tried searching the web for solutions, but haven't found anything, which is why I posted here. – Scoop – 2011-12-15T20:27:44.943

Wouldn't removing arama.php? from the string suffice? – slhck – 2011-12-16T14:28:57.247

Answers

1

you can use regex for this as others have suggested:

try something like

/arama.php\?([a-zA-Z]+)=([a-zA-Z]+)

replacement line would look something like

/\1=\2

BLSully

Posted 2011-12-15T19:39:40.720

Reputation: 111

If the solution was what you were looking for, please mark it answered. – BLSully – 2011-12-19T21:30:44.140