Skip to content

Commit

Permalink
Escape the hyphens in the roles regexes
Browse files Browse the repository at this point in the history
Inside square brackets, unescaped hyphens are position dependent. They
act like hyphens normally when at the beginning or end of a square
bracket expression. Otherwise it's used to signify a character range.

http://stackoverflow.com/questions/4068629/how-to-match-hyphens-with-regular-expression/4068725#4068725
  • Loading branch information
Reed Lipman committed Oct 24, 2012
1 parent 7f94fe0 commit 841dde3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/scripts/roles.coffee
Expand Up @@ -15,7 +15,7 @@ module.exports = (robot) ->
getAmbiguousUserText = (users) ->
"Be more specific, I know #{users.length} people named like that: #{(user.name for user in users).join(", ")}"

robot.respond /who is @?([\w .-]+)\?*$/i, (msg) ->
robot.respond /who is @?([\w .\-]+)\?*$/i, (msg) ->
joiner = ', '
name = msg.match[1].trim()

Expand All @@ -39,7 +39,7 @@ module.exports = (robot) ->
else
msg.send "#{name}? Never heard of 'em"

robot.respond /@?([\w .-_]+) is (["'\w: -_]+)[.!]*$/i, (msg) ->
robot.respond /@?([\w .\-_]+) is (["'\w: \-_]+)[.!]*$/i, (msg) ->
name = msg.match[1].trim()
newRole = msg.match[2].trim()

Expand All @@ -63,7 +63,7 @@ module.exports = (robot) ->
else
msg.send "I don't know anything about #{name}."

robot.respond /@?([\w .-_]+) is not (["'\w: -_]+)[.!]*$/i, (msg) ->
robot.respond /@?([\w .\-_]+) is not (["'\w: \-_]+)[.!]*$/i, (msg) ->
name = msg.match[1].trim()
newRole = msg.match[2].trim()

Expand Down

0 comments on commit 841dde3

Please sign in to comment.