Reputation: 31550
Apparently json schema doesn't like this regex: ^(?=.{1,63}$)([-a-z0-9]*[a-z0-9])?$
https://regex101.com/r/qsyUoQ/1
I get an error: pattern must be a valid regex
. This error means the regex pattern I'm using is invalid according to json schema.
My regex seems to be valid for most other parsers though. and json schema supports positive and negative look aheads and capture groups: https://json-schema.org/understanding-json-schema/reference/regular_expressions.html
Is there some json schema specific escaping I need to do with my pattern?
I'm at a loss to see what it doesn't like about my regex.
The regex I want will do the following:
Upvotes: 0
Views: 633
Reputation: 163217
You could simplify the pattern to use the character classes and quantifiers without using the lookahead and the capture group.
You can change the quantifiers, matching 0-62 chars allowing the -
and a single char without the -
as a single char would also mean that it is at the end.
^[-a-z0-9]{0,62}[a-z0-9]$
Upvotes: 2