Search code examples
javascriptregexhubot

Make hubot respond to a multiline message


I have a scenario where I want hubot to parse something. The command would be hubot parse this thing <the content>

The problem is, the content will generally be a long piece of text pasted in and it usually contains newline characters (line breaks). Here's my regex:

/parse this thing (.*\s*)/i

I'm able to get a response just fine, but only the first line of the content is being read in. Is there any way to get him to read the entirety of the pasted content, including all lines?

EDIT:

Adding a + makes it read the entire pasted content, but only saves the last line:

/parse this thing (.*\s*)+/i

Solution

  • Figured it out! For future reference (I'm bad at regular expressions):

    /parse this thing ((.*\s*)+)/i