I am trying to extract some data from URLs in a LOG file and I’m almost there but the last part I am stuck on.
Here is the regex I have come up with so far,
(\?.*\s+)
Example of URLs I am working with
json?userId=1234&email=blahblah@blah.com HTTP/1.1
And I want to pull out
userId=1234&email=blahblah@blah.com
Across multiple lines of similar URL lines. The regex above gets the right stuff at the start but does not stop after the whitespace. What am I missing to make it not include the ? and end at the white space properly?
Edit: Clarified question a bit.
This works in sed.
echo “json?userId=1234&email=blahblah@blah.com HTTP/1.1” | sed ‘s/.*?\(.*\)\s.*$/\1/
you might also try.
(\?[^\s]+)
match as many not space characters after a ?