Filtering substrings into a shortened list

(imported topic written by mvm-upenn91)

I’m trying to filter the list of users in the local administrators group so that it only returns users whose names do not contain certain strings. For example:

q: concatenation "; " of ((members of local group "Administrators") as string)
a: DOMAIN\regularuser; DOMAIN\adminuser; LOCALMACHINE\administrator; LOCALMACHINE\localuser

For one string, this works:

q: concatenation "; " of ((members of local group "Administrators") as string) whose ((it as lowercase) does not contain "admin")
a: DOMAIN\regularuser; LOCALMACHINE\localuser

What I’d like to do is enter multiple strings (does not contain “admin” and does not contain “user”, for example) to use as filters but I can’t seem to figure out how to get there. I’ve been trying to use tuples, but nothing’s quite working out. It’s probably pretty easy, but my mind isn’t getting around it right now. Any ideas on how to accomplish this?

(imported comment written by jeremylam)

I don’t think tuples are the right approach here. I think you just need to slightly change your “whose” clause:

How about:

q: concatenation ";" of ("DOMAIN\regularuser"; "DOMAIN\adminuser"; "LOCALMACHINE\administrator"; "LOCALMACHINE\localuser"; "DOMAIN\outsider") whose (it does not contain "admin" AND it does not contain "user")
A: DOMAIN\outsider

If you wanted a more flexible or complex way of filtering, I’d suggest using regular expressions:

q: concatenation ";" of ("DOMAIN\regularuser"; "DOMAIN\adminuser"; "LOCALMACHINE\administrator"; "LOCALMACHINE\localuser"; "DOMAIN\outsider") whose (NOT (it contains regex "user|admin"))
A: DOMAIN\outsider

(imported comment written by mvm-upenn91)

Great, those did the trick. I was trying to make it harder than it was, and was missing that I should move the NOT outside of the it. Everything is clear now… thanks for the help!