I have not been able to figure out how to properly escape `'/'` in a regular expression for the regex filter selector. Not sure if it is not currently possible or if it could just use an example in the documentation... ```python >>> doc = [{'type': 'studio/material/a'}, {'type': 'studio/material/b'}] ``` Without `'/'` (success) ```python >>> jsonpath.compile('$[?@type =~ /studio.*/]').findall(doc) [{'type': 'studio/material/a'}, {'type': 'studio/material/b'}] ``` With `'/'` (error expected) ```python >>> jsonpath.compile('$[?@type =~ /studio/material/.*/]').findall(doc) jsonpath.exceptions.JSONPathSyntaxError: expected TOKEN_COMMA, found 'TOKEN_NAME' -> '$[?@type =~ /studio/material/.*/]' 1:22 | 1 | $[?@type =~ /studio/material/.*/] | ^^^^^^ expected TOKEN_COMMA, found 'TOKEN_NAME' ``` With `'\/'` ```python >>> jsonpath.compile('$[?@type =~ /studio\/material\/.*/]').findall(doc) jsonpath.exceptions.JSONPathSyntaxError: unexpected token '\\' -> '$[?@type =~ /studio\\/material\\/.*/]' 1:29 | 1 | $[?@type =~ /studio\/material\/.*/] | ^ unexpected token '\\' ``` With `'\\/'` ```python >>> jsonpath.compile('$[?@type =~ /studio\\/material\\/.*/]').findall(doc) jsonpath.exceptions.JSONPathSyntaxError: unexpected token '\\' -> '$[?@type =~ /studio\\/material\\/.*/]' 1:29 | 1 | $[?@type =~ /studio\/material\/.*/] | ^ unexpected token '\\' ``` With `'\\\/'` ```python >>> jsonpath.compile('$[?@type =~ /studio\\\/material\\\/.*/]').findall(doc) jsonpath.exceptions.JSONPathSyntaxError: unexpected token '\\' -> '$[?@type =~ /studio\\\\/material\\\\/.*/]' 1:30 | 1 | $[?@type =~ /studio\\/material\\/.*/] | ^ unexpected token '\\' ```
Activity
jg-rp commentedon Jan 6, 2026
Hi @Omniflux,
This was a bug in the JSONPath parser. Should be fixed in version 2.0.2, now released.
Output