Text Match Expressions in EyeAuras are versatile tools for validating and matching text-based conditions specified by users. There are three types of evaluators available: Regex, Text, and Lambda.
These could be encountered in Text Search, Network Message, Telegram Message and some other types of triggers
The Text Evaluator works by performing a direct comparison with the specified text. It is case-sensitive, but you can choose to make it case-insensitive if you prefer.
Here are some examples of how you can use the Text Evaluator:
Hello World
This will match only the exact string "Hello World".12345
This will match the string "12345". Note that it will not match the number 12345 typed without the quotes.HELLO
With case-insensitivity turned on, this will match "hello", "Hello", "HELLO", etc.The quick brown fox jumps over the lazy dog
This will match the entire sentence exactly as it is.
The Regex Evaluator allows you to utilize regular expressions for more complex and flexible text matching conditions.
Here are a few examples:
Match any number Regex to match: \d+
This will match any string that represents a number, e.g., "123", "45678", etc.
Match any word Regex to match: \b\w+\b
This will match any string that represents a word, e.g., "Hello", "World", etc.
Match any two letters Regex to match: \b[a-zA-Z]{2}\b
This will match any string that represents exactly two letters, e.g., "ab", "cd", etc.
Match any three numbers Regex to match: \b\d{3}\b
This will match any string that represents exactly three numbers, e.g., "123", "456", etc.
Match any word starting with a specific letter Regex to match: \bH\w*\b
This will match any string that represents a word starting with the letter "H", e.g., "Hello", "Hi", etc.
Match any word ending with a specific letter Regex to match: \b\w*e\b
This will match any string that represents a word ending with the letter "e", e.g., "code", "node", etc.
The Lambda Evaluator is a powerful tool that enables you to write C# Lambda Expressions. This evaluator essentially converts a string to a boolean based on the conditions you set, offering a broad range of possibilities.
For example, you can create a lambda expression to check if a string is empty, if it contains specific characters, or even if it can be parsed into a number within a certain range.
Here are a few examples:
text => string.IsNullOrEmpty(text)
This will return True
for an empty string or Null
, and False
otherwise.text => text.Contains("Hello")
This will return True
if the string contains "Hello", and False
otherwise.text => text.Length < 5
This will return True
if the string length is less than 5, and False
otherwise.text => double.Parse(text) >= 1 && double.Parse(text) <= 100
This will return True
if the string can be parsed into a number between 1 and 100, and False
otherwise.
Test Mode is a valuable feature that allows you to enter a string value and verify that your expression functions as expected, reducing the chance of errors. You can use it to fine-tune your expressions to suit your needs.
Remember that all evaluators operate on strings, and they're compatible with any Unicode-compatible language. There are no limitations to the type of expressions you can create, and EyeAuras will warn you if your expression is not valid.