Reputation: 131
I try to define a DialogFlow CX custom entity for values like e.g. "0.23" using the Regex option and entering the following Regex: [+]?([.]\d+|\d+([.]\d+)?)
But DiglogFlow CX would not accept this Regex and throw the error Validate entity failed because of the following reasons: Regular expression match is too broad: [+]?([.]\d+|\d+([.]\d+)?)
I have this issue with many, many other Regex examples. Why can't I use Regex like the one above? This is not broad at all, right? This perfectly defines a very specific number format which I need. It seems I am somehow not understanding this all all...?!
Upvotes: 0
Views: 1155
Reputation: 228
The "Regular expression match is too broad." error occurs if the regular expression that you defined has a pattern that is not specific enough - which might result in it matching virtually anything or matching unlimited values with the same pattern.
For example, your regular expression [+]?([.]\d+|\d+([.]\d+)?)
can match multiple numbers with the sample pattern:
For your use case, you may consider using the @sys.number system entity instead. The @sys.number matches any ordinal and cardinal numbers including decimals.
However, if you prefer using a regular expression entity, you can use the one of the following syntax for accepting decimal numbers:
^[+]?([.]\d+|\d+([.]\d+)?)$
^ means beginning of text
$ means end of text
Note: The ^ and $ symbols prevent the regular expression from matching unlimited values with the same pattern. Ex. 23.23 13.31 23.12 0.113 …
[0-9]*[.][0-9]+
The syntax above will match these formats:
Dialogflow uses the Google RE2 syntax for Regular Expression.
Upvotes: 1