Basically, I have a file like this:
Url/Host: www.example.com
Login: user
Password: password
Data_I_Dont_Need: something_else
How can I use RegEx to separate the details to place them into variables?
Sorry if this is a terrible question, I can just never grasp RegEx. So another question would be, can you provide the RegEx, but kind of explain what each part of it is for?
You should put the entries in a dictionary, not in so many separate variables — clearly, the keys you’re using need NOT be acceptable as variable names (that slash in ‘Url/Host’ would be a killer!-), but they’ll be just fine as string keys into a dictionary.
and then
the possibility of making RE patterns “verbose” (by starting them with
(?x)or usingre.VERBOSEas the second argument tore.compile) is very useful to allow you to clarify your REs with comments and nicely-aligning whitespace. I think it’s sadly underused;-).