klorenz / atom-regex-railroad-diagrams

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

No difference between greedy and non-greedy regexes #23

Closed ilanbiala closed 9 years ago

ilanbiala commented 9 years ago

Ideally the diagram should be different if there is a /g at the end instead of /, because it means that the regex picks up all instances, and not just the first one.

nicolaiskogheim commented 9 years ago

The g is a global-modifier, which does what you say. The non-greedy-character is the question mark in [0-9]+? which makes my example match as little as possible, one number in this instance.

:smiling_imp:

ilanbiala commented 9 years ago

/a/ and /a/g produce the same regex, which could be misinterpreted...

ilanbiala commented 9 years ago

@klorenz is anything in the works for this?

klorenz commented 9 years ago

Hi,

there are two issues:

there is no work on this right now. How could it look like? any suggestions?

ilanbiala commented 9 years ago

Just put something like (global) or (greedy) somewhere at the end, or at least list the flags to start and see what people suggest.

hayes commented 9 years ago

greedy could be implemented the same way a repeat {n1,n2} is implemented, where it shows greedy rather than n1 to n2 times as text in the back track loop (not sure what to call it).

Not sure about flags, maybe a vertical list to the left or right of the diagram?

I mostly care about the greedy thing because that is interesting. Also could we make non-capturing groups have a dashed border (or something) I could open a separate issue.