Tip of the Week: How to search multiple strings for certain keywords?

This post has been republished via RSS; it originally appeared at: Azure Data Explorer articles.

ADX_Tips.png

 

Whenever you look for a way to search for multiple strings with specific keywords, you can leverage the following code Sample 

  • (?i) flag for case-insensitive lookup
  • \b for looking for full words (similar to ‘has’ string operator vs ‘contains’)
let any_of_the_following = dynamic(['FLORIDA','NEW YORK','GEORGIA']);
let any_of_the_following_regex = strcat(@'(?i)', @'\b(', strcat_array(any_of_the_following, "|"), @')\b');
datatable(tweet:string)
[
    'We saw heavy rain in Florida',
    'This string does not contain any state.',
    'FloridaShould appear separately.',
    'NEW YORK is still popular destination among tourists',
]
| where tweet matches regex any_of_the_following_regex

Tweet

We saw heavy rain in Florida

NEW YORK is still popular destination among tourists

 

“Join the conversation on the Azure Data Explorer community”.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.