watsonwatson-conversation

Why watson is not recognizing this regexp input.text.find("(\\d)\\1+")?


I'm trying to recognize repeated numbers from user text.

For example: 112345

Watson should recognize the repeated 1 (one) and respond with a specific text, however, is not recognizing that pattern.

I'm using the following to recognize that pattern which is not working:

input.text.find("(\\d)\\1+")


Solution

  • Sadly Watson Assistant does not support Backreferente on regex.

    Here is the documentation about that.

    "Entity patterns may not contain:

    • Positive repetitions (for example x*+)
    • Backreferences (for example\g1)
    • Conditional branches (for example (?(cond)true))"

    https://console.bluemix.net/docs/services/conversation/entities.html#defining-entities

    This part is specifically about the regex on entities, but in all my tests it's also valid for recognizing regex on text.input. Normally when we need to use more complex regex, we end up using at the application layer.