aichaos / rivescript-js

A RiveScript interpreter for JavaScript. RiveScript is a scripting language for chatterbots.
https://www.rivescript.com/
MIT License
377 stars 145 forks source link

regex support #320

Open dcsan opened 5 years ago

dcsan commented 5 years ago

there doesn't seem to be an open issue for regex at the moment I recall there was a working doc somewhere to discuss this but hope you don't mind if i make an issue here.

this is a missing feature for rivescript that means it can't be used effectively for non-latin languages chinese/japanese etc. the simplied regex syntax depends on spaces which doesn't work

and also the ? syntax which is to find a single word in a phrase

https://github.com/aichaos/rivescript-js/issues/262#issuecomment-517919849

BotML has first class support for regex and also some interesting ways to inline javascript for conditional testing https://github.com/codename-co/botml#regular-expression

~ listen_email
< Your email please?
> *{email}
---
  ` !/^.+@.+\..+/.test('$email')
  < This email $email seems not legit!

perhaps there is some inspiration there?