Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only matches when word acted on is the first? #4

Closed
patcon opened this issue Dec 11, 2013 · 7 comments
Closed

Only matches when word acted on is the first? #4

patcon opened this issue Dec 11, 2013 · 7 comments

Comments

@patcon
Copy link
Contributor

patcon commented Dec 11, 2013

Not sure if this is a bug or not. We used to be able to say things before the word we wanted to act on, and now this doesn't work. For example:

https://www.evernote.com/shard/s27/sh/4ac66797-e5b4-4144-913e-3a362400a211/f157a2c2d02642bc4871f8ef986bb067

Is this intentional?

Also, not familiar with "passive groups" (?:...) and how they work. Can we use a regex block and annotate it to explain some of this for others who are poking around?

https://github.com/ajacksified/hubot-plusplus/blob/master/src/pluspplus.coffee#L31

@ajacksified
Copy link
Owner

We can update the regex to ^(.+)?(?:[\W\s]*)?(\+\+|\-\-)(?: (?:for|because|cause|cuz) (.+))?$ which would result in haha erin has 1 points (because hubot doesn't know the difference between haha erin and patrick connolly, we'd need to allow all characters.)

Passive groups require that the character group matches, but does not end up in the resulting matches in the javascript array. I agree that the regex is getting a little out of hand.

@patcon
Copy link
Contributor Author

patcon commented Dec 12, 2013

What about adding a toggle to only match single words if we choose? We are using this as a replacement for the karma command in #drupal channels on IRC, and multiple words is not something we want by default. As suggested elsewhere, allowing multiple words by quoting would cover that small number of cases where someone might want that (ex: "dogs with poofy tails"++)

Thoughts?

@iamnirav
Copy link

I could see adding an option to match only single words (with multiple words needing to be quoted), but I don't think that should be the default.

@patcon
Copy link
Contributor Author

patcon commented Dec 12, 2013

Ok, cool! I'll work on this sometime :)

therealklanni added a commit to therealklanni/hubot-plusplus that referenced this issue Jun 1, 2014
Annotated the regex as suggested in ajacksified#4
@plukevdh
Copy link
Contributor

plukevdh commented Jan 7, 2015

Is this a dupe of #2?

@patcon
Copy link
Contributor Author

patcon commented Jan 7, 2015

They're both regex, but I think different issues to sort out. One is about ignoring (no match), and the other about misattribution of the plus'ed word (mismatching). Not even sure whether both are current issues though :)

@therealklanni
Copy link
Collaborator

I think we can close this now, phrases are supported.

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

No branches or pull requests

5 participants