Skip to content
Advertisement

How to split a string with space into two lines in python

I am trying to split github.com/pmezard/go-difflib v1.0.0 into name and version

I tried like this but it only split into 2. output i am getting is [{‘name’: ‘pmezard’, ‘version’: ‘v1.0.0n’}]

Expected output [{‘name’: ‘go-difflib’, ‘version’: ‘v1.0.0’}]

JavaScript

Advertisement

Answer

Considering all string of format github.com/pmezard/go-difflib v1.0.0

JavaScript

For complex pattern, regex may be helpful

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement