1
1
mirror of https://github.com/wader/fq.git synced 2024-09-11 12:05:39 +03:00

Merge pull request #668 from wader/trim-multiline

interp: trim: Add multi-line support
This commit is contained in:
Mattias Wadman 2023-05-12 00:35:04 +02:00 committed by GitHub
commit 070d5f43ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -5,7 +5,7 @@ include "decode";
def intdiv(a; b): _intdiv(a; b);
def trim: capture("^\\s*(?<str>.*?)\\s*$"; "").str;
def trim: capture("^\\s*(?<str>.*?)\\s*$"; "m").str;
# does +1 and [:1] as " "*0 is null
def rpad($s; $w): . + ($s * ($w+1-length))[1:];

View File

@ -71,3 +71,9 @@ streaks_by(.a)
["12"]
["12","34"]
["123","4"]
.[] | trim
["a", " abc ", "\n\t a\nb\n"]
"a"
"abc"
"a\nb"