I’m trying to write a hubot script that answers to two different kinds of input. A user can either input the name of a stop for the local public transport or optionally postfix this with a delay.
The input can therefore be
dvb zellescher weg or
dvb albertplatz for the first option or
dvb zellescher weg in 5 or
dvb albertplatz in 10 for the second.
(“dvb” here being the keyword for my script and “zellescher weg” and “albertplatz” being two examples for stop names)
On trying to match these with regex I’m running into an issue where a regex I’ve gotten to work on different testing sites (like regex101 which seems to be recommended here and does JS) won’t work in my code. The regex for matching input without a number is
/^dvb (D*)$/ and I’m using
/dvbs+(.*)in (d*)/ to match the cases where the user has entered a delay.
A minimal code example for my hubot that isn’t matching for reasons unbeknownst to me looks like this:
robot.respond /^dvb (D*)$/, (res) -> hst = res.match res.send hst
Thanks for any help on this.