Skip to content

Escaping '/' in regex filter selector #124

Description

@Omniflux

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...

>>> doc = [{'type': 'studio/material/a'}, {'type': 'studio/material/b'}]

Without '/' (success)

>>> jsonpath.compile('$[?@type =~ /studio.*/]').findall(doc)
[{'type': 'studio/material/a'}, {'type': 'studio/material/b'}]

With '/' (error expected)

>>> 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 '\/'

>>> jsonpath.compile('$[?@type =~ /studio\/material\/.*/]').findall(doc)
jsonpath.exceptions.JSONPathSyntaxError: unexpected token '\\'
  -> '$[?@type =~ /studio\\/material\\/.*/]' 1:29
  |
1 | $[?@type =~ /studio\/material\/.*/]
  |                              ^ unexpected token '\\'

With '\\/'

>>> jsonpath.compile('$[?@type =~ /studio\\/material\\/.*/]').findall(doc)
jsonpath.exceptions.JSONPathSyntaxError: unexpected token '\\'
  -> '$[?@type =~ /studio\\/material\\/.*/]' 1:29
  |
1 | $[?@type =~ /studio\/material\/.*/]
  |                              ^ unexpected token '\\'

With '\\\/'

>>> jsonpath.compile('$[?@type =~ /studio\\\/material\\\/.*/]').findall(doc)
jsonpath.exceptions.JSONPathSyntaxError: unexpected token '\\'
  -> '$[?@type =~ /studio\\\\/material\\\\/.*/]' 1:30
  |
1 | $[?@type =~ /studio\\/material\\/.*/]
  |                               ^ unexpected token '\\'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions