pythonregexpython-3.xpipenvvscodevim

What is the regex expression for removing pinned versions from a Pipfile?


Per the Pipenv documentation, when importing from a requirements.txt file with

pipenv install -r path/to/requirements.txt

it is recommended that

if your requirements file has version numbers pinned, you’ll likely want to edit the new Pipfile to remove those, and let pipenv keep track of pinning.

What regex to use when replacing these pinned version numbers after running pipenv install -r path/to/requirements.txt?

Since I prefer to use the vim search and replace command :%s/foo/bar, please structure your answer such that foo is replaced by bar, as above in vim, if possible. I mainly use vim keybindings in Visual Studio Code, so javascript-based regex is appropriate.


Solution

  • The following regex worked to solve this problem: "==([\S]+)".

    Use it via the Visual Studio Code Vim extension (and replace with a "*"):

    :%s/"==([\S]+)"/"*"
    

    or without the "*" (replacing with nothing):

    :%s/"==([\S]+)"/
    

    I used regexr to assist and learn the underlying regex above.