I am trying to parse a comma separated string keyword://pass@ip:port. The string is a comma separated string, however the password can contain any character including comma. hence I can not use a split operation based on comma as delimiter.
I have tried to use regex to get the string after "myserver://" and later on I can split the rest of the information by using string operation (pass@ip:port/key1) but I could not make it working as I can not fetch the information after the above keyword.
myserver:// is a hardcoded string, and I need to get whatever follows each myserver as a comma separated list (i.e. pass@ip:port/key1, pass2@ip2:port2/key2, etc)
This is the closest I can get:
import re
my_servers="myserver://password,123@ip:port/key1,myserver://pass2@ip2:port2/key2"
result = re.search(r'myserver:\/\/(.*)[,(.*)|\s]', my_servers)
using search I tries to find the occurrence of the "myserver://" keyword followed by any characters, and ends with comma (means it will be followed by myserver://zzz,myserver://qqq) or space (incase of single myserver:// element, but I do not know how to do this better apart of using space as end-indicator). However this does not come out right. How can I do this better with regex?
myservera hardcoded string? Do you need to get[ "password,123@ip:port/key1", "pass2@ip2:port2/key2" ]?[['password', '123@ip:port/key1'], ['pass2@ip2:port2/key2']]or 2)['password,123@ip:port/key1', 'pass2@ip2:port2/key2']? Sorry, you are being too verbose. Your input has nopass@ip:port/key1substring.