If I want to match the following: 5 numbers, then followed by one or more other characters, like 12345aabb or 99887bb.
How can I achieve that use match condition?
Related link: https://docs.microsoft.com/en-us/azure/governance/policy/concepts/definition-structure#conditions
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
@imeya Please use the match condition by setting the value to "#####." and let me know if that doesn't help you. Thanks.
@imeya In addition to the correct answer from @KrishnaG-MSFT, we have a Sample to show what this could look like: https://docs.microsoft.com/azure/governance/policy/samples/allow-multiple-name-patterns
Also, the new value accessor could be used to check for length of the name, test various parts with split, and more. You can read about value here: https://docs.microsoft.com/azure/governance/policy/concepts/definition-structure#value
@KrishnaG-MSFT, thank you, I will take a try later. just a quick question, if the match condition "#####" can represent "12345aabb", then it means the "match" somehow like "like" operator, right? if yes, what's the difference between them(match and like)?
thanks.
@DCtheGeek Thanks for the clarification! :)
@imeya To answer your question on match and like operators, yes, both are somehow similar here because of "." in match operator (which is explained here) in comparison with "*" wildcard in like operator but IMHO in general, the match operator ideally is for comparing regular expression (regex) pattern string but where as like operator uses wildcards to compare the string pattern.
The doc won't be updated until tomorrow, but there are new match-related conditions "matchInsensitively" and "notMatchInsensitively" to perform the checks without case-sensitivity.
You can see the PR here: #25308 and the updated doc should be live tomorrow morning.
@DCtheGeek Nice to know the update. Thanks. 👍
I have one general question! What if someone wants to use only match operator for complex regex comparision using typical characters like "[", "]", "?", "+?" (for example [0-9]{5}[a-z], [0-9]{5}[a-z]+, etc.), so does match operator work with characters other than "#", ".", "?" in future releases ?
@KrishnaG-MSFT RegEx expressions outside what match/like offer today (*, #, ., ?) isn't supported. It is, however, a very common issue on UserVoice and the team has marked it as Under Review. If RegEx support is added, it'll be documented right away.
@MicrosoftDocs/azure-cxp-triage I believe all questions are answered on this, so let's #please-close.
@imeya Closing this issue for now. If there are further questions regarding this matter, please reply and we will gladly continue the discussion.