Human-written demonstration (OpenAssistant volunteers)· OpenAssistant (human-written)
OpenAssistant Conversations (oasst2)
write a regex expression that find graphql queries or mutations in a file
In OpenAssistant data, “assistant” turns were written by human volunteers as demonstrations. They are not model outputs.
- User
write a regex expression that find graphql queries or mutations in a file
- Assistant
Certainly! Here's a regular expression pattern that can match GraphQL queries or mutations in a file:
/\b(query|mutation)\b\s*(\w+)?\s*{[\s\S]*?}/g
And here's an explanation:
- "\b(query|mutation)\b" matches the keyword query or mutation as a whole word.
- "\s*(\w+)?\s*" matches an optional identifier for the query/mutation (e.g. getUser).
- "{[\s\S]*?}" matches the entire query/mutation block, including the opening and closing curly braces { and }.
- The "/g" flag at the end of the pattern makes the expression match all occurrences in the input file.
I hope that helps, and if not, don't hesitate to correct me!
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →