Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Using RegEx Entity with other entitiy in Traning Phrase gives empty value for the parameter

n Dialogflow ES I am using a Regular Expression for the date format (DD/MM/YYYY) validation. If I have the training phrase as 22/05/2021 it works perfectly.

But I need to have the training phrase as 22/05/2021 sample@sample.com. When I use like that, for the date it gives empty value.

empty_mydate.png

Not even for this mydate validation, this is not working if I use any RegEx entity along with other entity in the same training phrase.

Dewmini_0-1666237657284.png

myDigit RegEx is ^[0-9]$

So can't it be used Regex entity along with other entity in the same training phrase in Dialogflow?

Solved Solved
0 4 1,035
1 ACCEPTED SOLUTION

Sorry for the delay in replying, I see that your regular expression is matching the end of the line with “$” after the digit (^[0-9]$). This would explain why you are able to capture the data when the training phrase contains only the digit, but not when additional data is located after (for example, “2 sample@sample.com” does not contain the EOL metacharacter after “2”, but having only “2” as the training phrase does).

If your date regular expression matches the end of the line as well, you’d see the same behavior. I made a quick intent using this expression to match “DD/MM/YYYY”: ^[0-9]{2}\/[0-9]{2}\/[0-9]{4}. As shown below, it captures both the date and Email:

Screenshot 2022-10-26 11.46.11 AM.png

 

View solution in original post

4 REPLIES 4

Do you experience this problem when adding multiple entities of any kind into a single phrase? Do you also see any difference if you edit the regular expression?

Yes. I only face this issue when adding RegExp entity with multiple other entities in single training phrase. It works fine if I have only this RegExp entity in the training phrase. I tried changing the regular expression; but the issue remains the same.

Sorry for the delay in replying, I see that your regular expression is matching the end of the line with “$” after the digit (^[0-9]$). This would explain why you are able to capture the data when the training phrase contains only the digit, but not when additional data is located after (for example, “2 sample@sample.com” does not contain the EOL metacharacter after “2”, but having only “2” as the training phrase does).

If your date regular expression matches the end of the line as well, you’d see the same behavior. I made a quick intent using this expression to match “DD/MM/YYYY”: ^[0-9]{2}\/[0-9]{2}\/[0-9]{4}. As shown below, it captures both the date and Email:

Screenshot 2022-10-26 11.46.11 AM.png

 

Thank you very much for your solution. It worked perfectly when I removed $ from my Regular Expression.

I am posting the RegExp used in case someone else needs it (only get the valid dates only, avoid dates like 31/02/2022, 35/18/2022). Got it from https://stackoverflow.com/a/20773444/1719133

(^(((0[1-9]|1[0-9]|2[0-8])[\/](0[1-9]|1[012]))|((29|30|31)[\/](0[13578]|1[02]))|((29|30)[\/](0[4,6,9]|11)))[\/](19|[2-9][0-9])\d\d)|(^29[\/]02[\/](19|[2-9][0-9])(00|04|08|12|16|20|24|28|32|36|40|44|48|52|56|60|64|68|72|76|80|84|88|92|96))