Skip to content
This repository was archived by the owner on May 26, 2018. It is now read-only.

/g flag for regex.py #9

Open
vladdeh opened this issue Jan 29, 2014 · 2 comments
Open

/g flag for regex.py #9

vladdeh opened this issue Jan 29, 2014 · 2 comments

Comments

@vladdeh
Copy link

vladdeh commented Jan 29, 2014

Would it be possible to have this disabled? At the moment it is on by default

@micolous
Copy link
Owner

micolous commented Feb 2, 2014

This has been a point of some debate on our own IRC channel at one point in time.

The reason that it was set this way is because of another regular expression bot on which this is based (as idea, not code), which also acted greedy by default (and had no non-greedy option).

The result of this behaviour is that sometimes it had some rather unintentional consequences which would be funny, and because non-greedy mode would only select the first match.

Unfortunately, not being greedy didn't always solve the problem of selecting what you meant rather than what actually matched first on the message stack. I found the majority of intended replacements were the result of someone else saying something while you were writing a regular expression for a previous message, and your regular expression would match the newer message instead. As a result, writing your regular expressions to be stricter tended to have better results, and this also addresses the excessive greediness issue.

I'm happy to have this as an option, but don't really think it should be a default behaviour.

@vladdeh
Copy link
Author

vladdeh commented Feb 2, 2014

I've ran into more issues with it being greedy that non-greedy but I see your point, having it as an option then it would be great if possible

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants