Regex describing a regex pattern? [closed]

2020-04-16 06:24发布

I am surprised that an answer to this is not easily found.

I am in the process of making a JSON schema. I have an object and one of it's properties is a string containing a regex pattern. This property must contain only regex.

So, this question is realistically two questions in one:

What is the regex pattern that describes regex patterns (javascript-compatible please)?

Secondly, how do I apply this to JSON schema (in the "pattern" property or even in the "patternProperty"1 property)?

1: I have no idea what purpose would require you to apply this in "patternProperty", but someone out there could find it useful

NOTE: Since, JSONschema is JSON and JSON is JavaScript-based, JavaScript scripters may find the solution (to the JSONschema-side of the question), as well as the problem, useful in their scripts.

1条回答
We Are One
2楼-- · 2020-04-16 06:51

Regexes can have nested parentheses.

Therefore, they are not describable by a regular expression.
Sorry.

查看更多
登录 后发表回答