atom-regex-railroad-diagrams
atom-regex-railroad-diagrams copied to clipboard
Python regex not showing
Diagrams are not showing for python regexes
None of these examples show a railroad diagram:
Simple Example
import re
re.search(r'abc', '123abcxyz')
Verbose Example
import re
email_regex = re.compile(
r'''
^\s* # string start, white-space tolerant
(?P<name>[a-z0-9_.+-]+) # name
@
(?P<domain>[a-z0-9-]+\.[a-z0-9-.]+) # domain
\s*$ # string end, white-space tolerant
''',
flags=re.IGNORECASE | re.VERBOSE
)
match = email_regex.search('[email protected]')
match.groupdict() # gives: {'domain': 'here.com', 'name': 'me'}
JS String Example
# a valid JS regex, expressed in a string
r"/^eReal\d+=(\d+\.)?\d+(,eReal\d+=(\d+\.)?\d+)*(,ts=\d+)?$/"
This is just a valid JS expression in a string expressed in Python.
The same regex works in a .js file, but not as a .py
This is seemingly a duplicate of #7, but the suggested line:
regex = re.compile(r'your great regex')
also yields no joy