55b757cf-b7ca-4f26-9223-45d2608b303c
prompter
write a regex expression that find graphql queries or mutations in a file
4e971f14-5def-4a2c-b599-088bbe2468ea
55b757cf-b7ca-4f26-9223-45d2608b303c
assistant
Here is a regular expression (regex) pattern that can be used to find GraphQL queries or mutations in a file:

```regex
/\b(query|mutation)\b[\s\S]*?\{[\s\S]*?\}/g
```

This pattern uses word boundaries (\b) to ensure that only complete words "query" or "mutation" are matched, and it uses a non-greedy wildcard match ([\s\S]*?) to capture the entire query or mutation block, including the curly braces. The g flag at the end of the pattern enables global matching, which allows multiple queries or mutations to be matched within the same file.

This is a basic pattern that can be customized to match the specific syntax of your GraphQL queries or mutations, if necessary.
59f41793-7f3a-480f-819f-b581faae1e7a
4e971f14-5def-4a2c-b599-088bbe2468ea
prompter
Thanks. Can you modify it so that it only returns those without this list of profanities:

arsehole, ass, asshole, bastard, bitch, bloody, brotherfucker, bullshit, cock, cocksucker, crap, cunt, dick, dickhead, dyke, fatherfucker, fuck, goddamn, godsdamn, holy shit, horseshit, in shit, kike, motherfucker, piss, prick, pussy, shit, shit ass, sisterfucker, slut, son of a bitch, son of a whore, spastic, turd, twat, wanker
cf6a5521-6b68-46a7-a018-f40f06e7ccf1
59f41793-7f3a-480f-819f-b581faae1e7a
assistant
You can use a negative character class with those profane words to exclude matches that contain them:
/\b(?:query|mutation)\b(?:[^\s\S]?['"]?(?:(?:arsehole|ass|asshole|bastard|bitch|...)[^'"]))[\s\S]?{[\s\S]?}/g

I added [^\s\S]? to allow any number of non-word, non-whitespace characters ('"`]) before the exclusion list, in case any of the profane words were part of longer words.
The ... is just an ellipsis to represent the full list of excluded words you would insert.