sileht / python-jsonpath-rw-ext

Extensions for JSONPath RW
Apache License 2.0
59 stars 19 forks source link

return original value if `sub` didn't match any pattern #30

Open Janim007 opened 3 years ago

Janim007 commented 3 years ago

python sub method always return the original value even if there was no match and replacement. to be consistent with python, this PR propose to remove checking if value hasn't changed and return the original value as it as. current behavior:

>>> re.sub(r'foo', 'bar', 'github')
''

expected behavior:

>>> re.sub(r'foo', 'bar', 'github')
'github'