[Solved] regular expression to remove string following [closed]


Instead of gawk, I would recommend using gnu sed for this:

$ s="http://www.example.com/product/9896341.html?utm_source=google&utm_medium=VRM&utm_campaign=N&cid=vizuryjz&utm_content=&color=red&pid=9896341"
$ sed -r 's/utm_source=[^&]+//' <<<"$s"
http://www.shopin.net/product/9896341.html?&utm_medium=VRM&utm_campaign=N&cid=vizuryjz&utm_content=&color=red&pid=9896341

This deletes utm_source= followed by anything up to the next ampersand.

1

solved regular expression to remove string following [closed]