Blog Post

Azure Data Explorer Blog
1 MIN READ

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

Tzvia's avatar
Tzvia
Icon for Microsoft rankMicrosoft
Feb 19, 2019

 

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”.

Updated Feb 21, 2019
Version 4.0
No CommentsBe the first to comment