Regex describing a regex pattern? [closed]

梦想的初衷 提交于 2019-12-02 06:32:59

问题


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:


Regexes can have nested parentheses.

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



来源:https://stackoverflow.com/questions/37535865/regex-describing-a-regex-pattern

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!