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

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

Projects

None yet

5 participants

@patcon

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
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

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

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

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

@therealklanni therealklanni added a commit to therealklanni/hubot-plusplus that referenced this issue Jun 1, 2014
@therealklanni therealklanni annotated regex, bro
Annotated the regex as suggested in #4
3c8cd2d
@plukevdh

Is this a dupe of #2?

@patcon

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
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