https://github.com/potatomaster101/quotesc
Quote escaper
https://github.com/potatomaster101/quotesc
escape-double-quotes escape-inner mit-license python3
Last synced: 12 months ago
JSON representation
Quote escaper
- Host: GitHub
- URL: https://github.com/potatomaster101/quotesc
- Owner: PotatoMaster101
- License: mit
- Created: 2019-08-01T05:34:32.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-03T05:24:54.000Z (almost 7 years ago)
- Last Synced: 2025-02-21T09:48:48.858Z (over 1 year ago)
- Topics: escape-double-quotes, escape-inner, mit-license, python3
- Language: Python
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Quote Escape
Escapes inner and outer quotes in a string based on their location.
# Usage
Syntax:
```
$ python3 quotesc.py [-h] [-f] [-q QUOTE] [-l LVL] [-o OUTF] input
```
Escape double quotes from a simple file:
```
$ cat test.txt
"x"xx"xxx"xx"x"
$ python3 quotesc.py -f test.txt
"x\"xx\\\"xxx\\\"xx\"x"
```
Escape double quotes from CLI input:
```
$ python3 quotesc.py '"a"b"c"'
"a\"b\"c"
```
Change initial escape level:
```
$ python3 quotesc.py '"a"b"c"' -l 2
\\\"a\\\\\\\"b\\\\\\\"c\\\"
```
Escape other characters instead of double quotes:
```
$ python3 quotesc.py "'a'b'c'" -q \'
'a\'b\'c'
```
Reset the escape level on newline characters:
```
$ cat test.txt
"x"xx"xxx"xx"x"
"x"xx"xxx"xx"x"
"x"xx"xxx"xx"x"
"x"xx"xxx"xx"x"
"x"xx"xxx"xx"x"
"x"xx"xxx"xx"x"
"x"xx"xxx"xx"x"
"x"xx"xxx"xx"x"
$ python3 quotesc.py -f test.txt -r
"x\"xx\\\"xxx\\\"xx\"x"
"x\"xx\\\"xxx\\\"xx\"x"
"x\"xx\\\"xxx\\\"xx\"x"
"x\"xx\\\"xxx\\\"xx\"x"
"x\"xx\\\"xxx\\\"xx\"x"
"x\"xx\\\"xxx\\\"xx\"x"
"x\"xx\\\"xxx\\\"xx\"x"
"x\"xx\\\"xxx\\\"xx\"x"
```
Write output to file:
```
$ python3 quotesc.py '"e"s"c"a"p"e"m"e"!"' -o output.txt
$ cat output.txt
"e\"s\\\"c\\\\\\\"a\\\\\\\\\\\\\\\"p\\\\\\\\\\\\\\\"e\\\\\\\"m\\\"e\"!"
```