Skip to content Skip to sidebar Skip to footer

Regex To Match Multiple Words In Any Order

I'm writing a python script which will mark output for a Windows CIS benchmark. In order to do this I am matching values in group policy settings with a regex to see if they meet t

Solution 1:

How about

^[(Administrators)(LOCAL SERVICE)(NETWORK SERVICE),\s]+$

or

^(Administrators|LOCAL SERVICE|NETWORK SERVICE|[,\s])+$

see working at https://regex101.com/r/oJF0aW/2/tests

both versions basically say that the whole string must contain only the specified user names as well as commas and whitespace.


Post a Comment for "Regex To Match Multiple Words In Any Order"