AI Zone Admin Forum Add your forum

NEWS: survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

Check for match on variable value


How can I pattern match on the value of a variable? For example I have variables for $users_fname and $users_lname that may be populated with any text strings and I want to match on those values.

If $users_fname=Helen and $user_lname=Turner I want the following to match but I don’t want a different name to match:

My name is Helen Turner and I live on the moon. (match)

My name is Fred Smith and I live on the moon. (not a match)

Thank you.




  [ # 1 ]

The simplest pattern is:

( name is $users_fname? $users_lname? )

The question mark after the variable converts the test from mere existence of a value in that variable to a dynamic match on the value of the variable.

Note there are some limitations with multiple word values - see the section in the Pattern Redux document.


  [ # 2 ]

Great, thanks Andy!


  login or register to react