I have log of Apache and each line of file looks like:
script.php?variable1=value1&variable2=value2&variable3=value3&.........................
I need to take out this part of string:
variable1=value1&variable2=value2
and ignore the rest of line. How I can do this in PowerGREP?
I tried:
variable1=(.*)&variable2=(.*)&
But I get rest of line after value2.
Please help me, sorry for my english.
Replace
.with[^&]and drop the final&, like this:.will match anything it can (any character except for the newline character, basically).[^&], on the other hand, matches only characters that are not&.For even better results and faster performance, you can also replace the first
.in the same way and add?(the non-greedy qualifier), like so:Here's a working demo.