Skip to content

validate regular expressions? #2913

Closed Answered by itchyny
lsloan asked this question in Q&A
Discussion options

You must be logged in to vote

Using the input as the regex filter argument can validate the regexes.

 $ echo '".*" "[a]" "*" "["' | jq '. as $pattern | try ("" | test($pattern) | true) catch (startswith("Regex failure") | not)'
true
true
false
false

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by emanuele6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants