Python is about reading the code and understands what is happening. That is what I like about Python. Regex is in general hard to read. codinghorror explains this very well, and also made a suggestion to split up the regular expression in multiple line for readability.
Code
F.e I have the working regex :
vms_list = re.findall(r'"[^"]*"', vms)
I would like to do something like :
vms_list = re.findall(r'
" # find token "
[^"] # find any char which is no " token
* # repeat this until
" # token " is found again
', vms)
Solution :
vms_list = re.findall(r""" # start
["] # find token double quote, surround with square brackets
[^"] # find token which is not token double quote
* # repeat this until
["] # # until token double quote is found again
""", vms, re.VERBOSE) # close
Research
I have searched for multiline regex, with many response, but not about the readability of regex.
Composed Regular Expressions - breaking a regex down into a readable form from 2009 came close but without a solution.
IgnorePatternWhitespace is advised to used like in codehorror blog. But I can not find it, or something similar, for Python.
Readability
This would really improve the readability of my Python regex. Is something like this possible in Python?