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

RegEX to identify a custom name in the middle of sentence in Dialogflow ES.

I'm trying to identify the project name from the given input using a regular expression in Dialogflow ES. Name can be in anywhere in the message. It only consists alphanumeric and hyphen(-) and It should not exceed 255 characters.

I tested adding several regex combinations. But everything was failed to identify the project name correctly. Please help me to find the suitable regex pattern for my use case.

piyumiuththara_1-1689171052548.png

Additionally, I want to recognize the project name when it is given as a separate single input following the regex ^[a-zA-Z0-9\-]{1,255}$ . But this regex does not supported in Dialogflow. Can you suggest a alternative regex which can be used in Dialogflow ES. 

  Thank you. 

 

Solved Solved
0 1 546
1 ACCEPTED SOLUTION

Good day @piyumi-uththara,

Welcome to Google Cloud Community!

This issue is happening since the expression is too broad, based on the project name, you are trying to capture Xyxp-7, Assuming that this is the naming convention you are trying to follow letters-digits try using this regex instead and see if it works:

 

\w{1,127}\-\d{1,128}

 

View solution in original post

1 REPLY 1

Good day @piyumi-uththara,

Welcome to Google Cloud Community!

This issue is happening since the expression is too broad, based on the project name, you are trying to capture Xyxp-7, Assuming that this is the naming convention you are trying to follow letters-digits try using this regex instead and see if it works:

 

\w{1,127}\-\d{1,128}