Zirak / SO-ChatBot

Other
124 stars 60 forks source link

!!learn input regex is weird #251

Closed caub closed 8 years ago

caub commented 8 years ago

I'd like to capture the first word and the rest of the input in 2 groups
With the bot:

!!learn trl "--$0---$1---$2--" "(\\w+) (.+)"
!!trl aa bb cc dd
@crl --aa bb cc dd--1--2--

Why doesn't it behave like that:

'aa bb cc dd'.replace(new RegExp('(\\w+) (.+)'), '--$0---$1---$2--')
> "--$0---aa---bb cc dd--"

it should, right? https://github.com/Zirak/SO-ChatBot/blob/307bd071622571187fb4f3462ea4814cc38fdbcf/source/plugins/learn.js#L34

caub commented 8 years ago

got it, should be

!!learn trl --$0---$1---$2-- "(\\w+) (.+)"

would be less confusing if we had to put wrapping quotes everywhere or nowhere