Home
%3CLINGO-SUB%20id%3D%22lingo-sub-353229%22%20slang%3D%22en-US%22%3ETip%20of%20the%20Week%3A%20How%20to%20search%20multiple%20strings%20for%20certain%20keywords%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-353229%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20502px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F83723iAC7E24E692DA0051%2Fimage-dimensions%2F502x297%3Fv%3D1.0%22%20width%3D%22502%22%20height%3D%22297%22%20alt%3D%22ADX_Tips.png%22%20title%3D%22ADX_Tips.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhenever%20you%20look%20for%20a%20way%20to%20search%20for%20multiple%20strings%20with%20specific%20keywords%2C%20you%20can%20leverage%20the%20following%20code%20Sample%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%20style%3D%22font-weight%3A%20400%3B%22%3E(%3CFONT%20color%3D%22%23008000%22%3E%3Fi%3C%2FFONT%3E)%20flag%20for%20case-insensitive%20lookup%3C%2FLI%3E%0A%3CLI%20style%3D%22font-weight%3A%20400%3B%22%3E%3CFONT%20color%3D%22%230000ff%22%3E%5Cb%3C%2FFONT%3E%20for%20looking%20for%20full%20words%20(similar%20to%20%E2%80%98has%E2%80%99%20string%20operator%20vs%20%E2%80%98contains%E2%80%99)%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3Elet%20any_of_the_following%20%3D%20dynamic(%5B'FLORIDA'%2C'NEW%20YORK'%2C'GEORGIA'%5D)%3B%0Alet%20any_of_the_following_regex%20%3D%20strcat(%40'(%3CFONT%20color%3D%22%23008080%22%3E%3Fi%3C%2FFONT%3E)'%2C%20%40'%3CFONT%20color%3D%22%230000ff%22%3E%5Cb%3C%2FFONT%3E('%2C%20strcat_array(any_of_the_following%2C%20%22%7C%22)%2C%20%40')%3CFONT%20color%3D%22%230000ff%22%3E%5Cb%3C%2FFONT%3E')%3B%0Adatatable(tweet%3Astring)%0A%5B%0A%20%20%20%20'We%20saw%20heavy%20rain%20in%20Florida'%2C%0A%20%20%20%20'This%20string%20does%20not%20contain%20any%20state.'%2C%0A%20%20%20%20'FloridaShould%20appear%20separately.'%2C%0A%20%20%20%20'NEW%20YORK%20is%20still%20popular%20destination%20among%20tourists'%2C%0A%5D%0A%7C%20where%20tweet%20matches%20regex%20any_of_the_following_regex%0A%3C%2FPRE%3E%0A%3CTABLE%20width%3D%22291%22%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22287%22%3E%0A%3CP%3E%3CFONT%20color%3D%22%23999999%22%3ETweet%3C%2FFONT%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22287%22%3E%0A%3CP%3EWe%26nbsp%3Bsaw%26nbsp%3Bheavy%26nbsp%3Brain%26nbsp%3Bin%26nbsp%3BFlorida%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22287%22%3E%0A%3CP%3ENEW%26nbsp%3BYORK%26nbsp%3Bis%26nbsp%3Bstill%26nbsp%3Bpopular%26nbsp%3Bdestination%26nbsp%3Bamong%26nbsp%3Btourists%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CI%3E%3CSPAN%20style%3D%22font-size%3A%2011.0pt%3B%20font-family%3A%20'Calibri'%2Csans-serif%3B%22%3E%E2%80%9CJoin%20the%20conversation%20on%20the%20%3CA%20href%3D%22https%3A%2F%2Femea01.safelinks.protection.outlook.com%2F%3Furl%3Dhttps%253A%252F%252Ftechcommunity.microsoft.com%252Ft5%252FAzure-Data-Explorer%252Fbd-p%252FKusto%26amp%3Bdata%3D02%257C01%257Ctzgitlin%2540microsoft.com%257C9f50757c112e45322d5608d697587c18%257C72f988bf86f141af91ab2d7cd011db47%257C1%257C0%257C636862803655308273%26amp%3Bsdata%3DSuximQlW7qkiSzSZyJHW9SP4vX1calRCPs4P2HTneII%253D%26amp%3Breserved%3D0%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Data%20Explorer%20community%3C%2FA%3E%E2%80%9D.%20%3C%2FSPAN%3E%3C%2FI%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-353229%22%20slang%3D%22en-US%22%3E%3CP%3EIf%20you%20ask%20yourself%20how%20to%20search%20multiple%20strings%20for%20certain%20keywords%2C%20this%20tip%20is%20for%20you.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20502px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F83723iAC7E24E692DA0051%2Fimage-dimensions%2F502x297%3Fv%3D1.0%22%20width%3D%22502%22%20height%3D%22297%22%20alt%3D%22ADX_Tips.png%22%20title%3D%22ADX_Tips.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-353229%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Data%20Explorer%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ETip%20of%20the%20Week%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E

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