0

I have a large list (100,000+) of URLS with parameters like so:

https://www.example.com?a=b&1=2&me=you
https://www.example.com?a=b

I'm using VIM need a regex to replace all values with whatever I desire, like so:

https://www.example.com?a=value&1=value&me=value
https://www.example.com?a=value

Also, I'm not limited to a Regex, if someone has a solution using norm or sed, that would also work. I just need to be able to automate it.

3
  • 1
    s/\([^&?]*=\)[^&]*/\1value/g
    – Quasímodo
    Commented Dec 14, 2022 at 1:22
  • 1
    That works, just need the %s. You should've answered traditionally so I could mark it answered! Thank you so much though!
    – ex7lted
    Commented Dec 14, 2022 at 4:06
  • @Quasímodo agreed; this could be an answer
    – D. Ben Knoble
    Commented Dec 15, 2022 at 16:02

1 Answer 1

0

Quasimodo commented the solution, so I'll post here so I can mark this answered:

To replace each value between = and &, and everything after the final =, if it's the last parameter in a URL, for every line in a file, this works:

%s/\([^&?]*=\)[^&]*/\replacement/g
1
  • You meant \1replacement
    – Quasímodo
    Commented Dec 31, 2022 at 17:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.