klorenz / atom-regex-railroad-diagrams

display regex as railroad diagram, if cursor moves to it
MIT License
250 stars 31 forks source link

Python regex not showing #113

Open fragmuffin opened 5 years ago

fragmuffin commented 5 years ago

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('me@here.com')
match.groupdict()  # gives: {'domain': 'here.com', 'name': 'me'}

(more complex example)

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