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.
deepak198486
Apr 23, 2021Copper Contributor
I have the regex which identifies it and get the results but i want the results not matching the regex. Is there any command or function to achieve this
- JBUB_AcceleryntApr 23, 2021Brass Contributor
Can you post the complete query? We will be able to help.
Have you tried using the "| where not" xxxxxxx feature?
- deepak198486Apr 23, 2021Copper ContributorThanks
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
- CliveWatsonApr 23, 2021
Microsoft
There is also substring. https://docs.microsoft.com/en-gb/azure/data-explorer/kusto/query/substringfunction
let name_ = "thisisanZme";
print a= substring(name_,8, 1)
| where a != "Z"