1

I want to build a conversation where customers needs to fill in there customer number. The customer number is always build in the format XX-XX-XXXXXX (2 numbers-2 numbers-6 numbers).

I don't have too much experiences with DialogflowCX or in general with too technical stuff. I know how to request a complete string of numbers with: ^[0-9]{10}$ but how do I manage that I force customers to also type the - sign in their answer.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83

1 Answers1

1

I recommend that you build regular expressions at regex101.com, it is easy to use and allows you to quickly test against examples.

For your specific problem, this is a regular expression which will work:

[0-9]{2}-[0-9]{2}-[0-9]{6}

I recommend to not use ^ and $ unless you really want to restrict a parameter input to the specific entity.

Here is the difference, let's assume the following input

My customer number is 12-34-567890

A parameter with a regular expression entity type containing [0-9]{2}-[0-9]{2}-[0-9]{6} matches the customer number as expected, but the customer number is not matched with ^[0-9]{2}-[0-9]{2}-[0-9]{6}$.

Florian Feldhaus
  • 5,567
  • 2
  • 38
  • 46
  • Thank you very much for your help! I never tought it would be that simple just adding the '-' between. Had troubles when I tried it but I think it is due the ^or $. And thanks for the link. I would really want to practice it and try some things with it just to learn and perhaps who knows what it can deliver :D! – Raymond Douwes Jul 15 '22 at 14:55
  • Glad I could be of help. Please don't forget to mark the answer as accepted and maybe consider up voting it. – Florian Feldhaus Jul 15 '22 at 16:36