Get stdout line substring based on regexp.
Project description
GetSubStr
Utility that allows you get substring of each stdout line based on regexp.
usage: getsub [-h] [-l CUT_LEFT] [-r CUT_RIGHT] [--lwrap L_WRAP]
[--rwrap R_WRAP] [-s] [-j JOIN_RESULTS]
[--join-matches JOIN_MATCHES] [-i]
regexp_pattern
Get stdout line substring based on regexp.
positional arguments:
regexp_pattern Regexp pattern
optional arguments:
-h, --help show this help message and exit
-l CUT_LEFT, --left-cut CUT_LEFT
Cut N chars from left side of result
-r CUT_RIGHT, --right-cut CUT_RIGHT
Cut N chars from right side of result
--lwrap L_WRAP Wrap results from left side by specified char(s)
--rwrap R_WRAP Wrap results from left side by specified char(s)
-s, --strip Strip spaces from left and right side of result
-j JOIN_RESULTS, --join-results JOIN_RESULTS
Join all results with specified char(s)
--join-matches JOIN_MATCHES
Join more regexp matches with specified char(s).
Default is TAB \t
-i, --ignore-errors Ignore errors caused regexp.
example #1:
printf "**** Error while updating article content id=498 ****\n**** Error while updating article content id=512 ****\n" \
| getsub "id\=\d+" -l 3 -j "," --lwrap "\"" --rwrap "\""
output:
"498","512"
example #2:
printf "123 456\n789 012" | getsub "(\d+) (\d+)" --o "i='{0}'...j='{1}'"
output:
i='123'...j='456'
i='789'...j='012'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
GetSubString-1.0.2.tar.gz
(3.7 kB
view hashes)
Built Distributions
GetSubString-1.0.2-py3.8.egg
(6.6 kB
view hashes)
Close
Hashes for GetSubString-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d5f242e03389a1ef1a84b4274ce018f38451f110b3d2d08c8109ca46708d5b9 |
|
MD5 | 16949d05eea81e7e23200b5ed3e0e7ef |
|
BLAKE2b-256 | 40d53f51a127b05ed2545cac5bc75eec1ff119a4d9e9e5a311d90c5c8c71bbd1 |