Regex - cheat sheet
string value extracteur into a dictionnary
import re
def str_to_dict_from_regex(string_value, regex):
pattern = re.compile(regex)
extraction = pattern.match(string_value)
return extraction.groupdict()
Database url extraction pattern
Example:
postgres://johndoe:597f99fb704c5259c@127.0.0.1:5432/db_name
.+:\/\/(?P<username>.+):(?P<password>.+)@(?P<host>[\W\w-]+):(?P<port>\d+)\/(?P<database>.+)
Comments