2

I'm trying to build a RegEx and put in an entity in Dialogflow that checks that the number of characters in a string (I also need whitespaces, numbers and specials) are between 0 and 130.

The following regular expression is correct, but Dialogflow tells me that "Regular expression match is too broad":

^(.){0,130}$ or ^([\s\S]){0,130}$

Is there a way doing this without coding?

  • Does it not like the `.` ? If you try `\w` that gets you alpha numeric (but no specials). If `\w` works then we can expand to `[\w!@#$%^.....]` to add the specials you want. Just thinking that error is complaining about `too broad` and `.` is the only broad thing. And you can actually just try `[\x20-\x7E]` which is the hex for basic latin character set (what you see on your keyboard). If that works let me know and I'll write up a nice answer with it :) – sniperd Jun 24 '22 at 12:47
  • And `^.{0,130}$`? – Wiktor Stribiżew Jun 24 '22 at 13:30
  • Programming languages usually have a `Length` method or property which returns the number of characters inside the string. Isn't it available in your case? – Persian Brat Jun 24 '22 at 20:39
  • Hi @MostafaF.Rad, Regular expressions cannot be given without coding. For your requirement, you can try this regex `^(\w\W\d\D\s\S.){0,130}$` or `^(\s,\S){0,130}$`. The `.` is very broad that covers all the characters and a regular expression can have a maximum of 1024 characters.Let me know if that fulfills your requirement. – Shipra Sarkar Jun 25 '22 at 13:05

0 Answers0