Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ Extensions
| sub | - $.field.`sub(/foo\\\\+(.*)/, \\\\1)` |
+--------------+----------------------------------------------+
| split | - $.field.`split(+, 2, -1)` |
| | - $.field.`split(sep, segement, maxsplit)` |
| | - $.field.`split(sep, segment, maxsplit)` |
+--------------+----------------------------------------------+
| sorted | - $.objects.`sorted` |
| | - $.objects[\\some_field] |
Expand Down
2 changes: 1 addition & 1 deletion jsonpath_ng/ext/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


SUB = re.compile("sub\(/(.*)/,\s+(.*)\)")
SPLIT = re.compile("split\((.),\s+(\d+),\s+(\d+|-1)\)")
SPLIT = re.compile("split\((.),\s+(-?\d+),\s+(\d+|-1)\)")
STR = re.compile("str\(\)")


Expand Down
10 changes: 10 additions & 0 deletions tests/test_jsonpath_rw_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,16 @@ class Testjsonpath_ng_ext(testscenarios.WithScenarios,
data={'payload': "foo-bar-cat-bow"},
target=["cat-bow"]
)),
('split3', dict(
string='payload.`split(-, -2, -1)`',
data={'payload': "foo-bar-cat-bow"},
target=["cat"]
)),
('split4', dict(
string='payload.`split(-, -2, 2)`',
data={'payload': "foo-bar-cat-bow"},
target=["bar"]
)),

('bug-#2-correct', dict(
string='foo[?(@.baz==1)]',
Expand Down