1
1
mirror of https://github.com/wader/fq.git synced 2024-10-26 11:49:54 +03:00

interp: trim: Add multi-line support

This commit is contained in:
Mattias Wadman 2023-05-12 00:21:35 +02:00
parent f254b16cfc
commit d5ae11659f
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"