jsonnet
jsonnet copied to clipboard
Add RegEx support using RE2 (rebased #665)
Rebased #665:
Introduces 5 new built-in methods to the stdlib:
regexFullMatch(pattern, str)-- Full match regexregexPartialMatch(pattern, str)-- Partial match regexregexQuoteMeta(str)-- Escape regex metachararactersregexReplace(str, pattern, to)-- Replace single occurance using regexregexGlobalReplace(str, pattern, to)-- Replace globally using regexSince both
regexFullMatchandregexPartialMatchcan perform captures these functions return a "match" object upon match ornullotherwise. For example:$ ./jsonnet -e 'std.regexFullMatch("h(?P<mid>.*)o", "hello")' { "captures": [ "ell" ], "namedCaptures": { "mid": "ell" }, "string": "hello" }Introduces a dependency on RE2 2019-06-01. Builds tested using make, CMake and Bazel on Ubuntu 18.04.
I ran make and make test on Linux, not sure how to trigger TravisCI.
Anything else I should address? @sparkprime @sbarzowski
Sorry it took so long to reply. Looks mostly good. Left some minor comments.
After I've done the current release (hopefully today) let's move forward on regex support in both impls for the next release.
After I've done the current release (hopefully today) let's move forward on regex support in both impls for the next release.
Sounds good!