Forum Discussion
deepak198486
Apr 23, 2021Copper Contributor
i am trying to fetch the machine list which does not contain letter " l " in 8th position.
I am trying to fetch the machine list which does not contain letter " l " in 8th position. can i use Kusto regex to achieve this. I only see matches regex command.
JBUB_Accelerynt
Apr 23, 2021Brass Contributor
Can you post the complete query? We will be able to help.
Have you tried using the "| where not" xxxxxxx feature?
deepak198486
Apr 23, 2021Copper Contributor
Thanks
I used the not operator and it worked.
Meanwhile below is the query
SecurityRecommendation
| where RecommendationName == "Disk encryption should be applied on virtual machines"
| where RecommendationState in ("NotApplicable", "Unhealthy")
| extend field = split(AssessedResourceId, '/')
| extend VM = tostring(field[8])
| extend resourceGroups = tostring(field[4])
| extend subscriptions = tostring(field[2])
| where not(VM matches regex "^.......[l].*") == true
| project VM, RecommendationDisplayName, resourceGroups, subscriptions, TimeGenerated
| extend HostCustomEntity = VM
I used the not operator and it worked.
Meanwhile below is the query
SecurityRecommendation
| where RecommendationName == "Disk encryption should be applied on virtual machines"
| where RecommendationState in ("NotApplicable", "Unhealthy")
| extend field = split(AssessedResourceId, '/')
| extend VM = tostring(field[8])
| extend resourceGroups = tostring(field[4])
| extend subscriptions = tostring(field[2])
| where not(VM matches regex "^.......[l].*") == true
| project VM, RecommendationDisplayName, resourceGroups, subscriptions, TimeGenerated
| extend HostCustomEntity = VM
- GaryBusheyApr 23, 2021Bronze Contributor
deepak198486 You can also try just plain indexof() to see if it is faster than using the regex.
| indexof(VM,"l",8,1)==-1
- deepak198486Apr 26, 2021Copper ContributorHi
I tried using indexof(VM,"l",8,1)==-1 but it is not giving the expected result.
I even tried with indexof_regex() but it also not giving the expected result.- GaryBusheyApr 26, 2021Bronze ContributorSorry, forgot the indexof starts its indexed with zero so it would would indexOf(VM,"l",7,1) but in my testing it doesn't seem to be faster.