python中tr/sed replace的替换
riptr的Python项目详细描述
riptr
类似于tr
或sed s//
的文本替换,但没有挫折感。使用普通的旧python regex样式。
安装
现在已部署到pypi,安装时使用:
pip install riptr
这会将riptr
和rtr
cli工具添加到python环境路径中。
用法
echo"some example text 1234" > test.file # default output is stdout riptr -m "^(.*?)([\d]{2})" -s "\g<1>56" test.file some example text 5634# specify patch mode 'p' riptr -m "^(.*?)([\d]{2})" -s "\g<1>56" -o p test.file --- +++ @@ -1 +1 @@ -some example text 1234 +some example text 5634# or inplace riptr -m "^(.*?)([\d]{2})" -s "\g<1>56" -o i test.file cat test.file some example text 5634