gsub function

This commit is contained in:
John Kerl 2015-10-11 18:21:23 -07:00
parent 3a96009986
commit 63d03e79b9
2 changed files with 50 additions and 4 deletions

View file

@ -4162,6 +4162,51 @@ HELLO HELLO
world world
WORLD WORLD
mlr --opprint put $y = sub($x, "a", "aa") ./reg_test/input/gsub.dat
x y
lmnop lmnop
abcdefg aabcdefg
ababbabbba aababbabbba
LMNOP LMNOP
ABCDEFG ABCDEFG
ABABBABBBA ABABBABBBA
mlr --opprint put $y = gsub($x, "a", "aa") ./reg_test/input/gsub.dat
x y
lmnop lmnop
abcdefg aabcdefg
ababbabbba aabaabbaabbbaa
LMNOP LMNOP
ABCDEFG ABCDEFG
ABABBABBBA ABABBABBBA
mlr --opprint put $y = gsub($x, "A", "Aa") ./reg_test/input/gsub.dat
x y
lmnop lmnop
abcdefg abcdefg
ababbabbba ababbabbba
LMNOP LMNOP
ABCDEFG AaBCDEFG
ABABBABBBA AaBAaBBAaBBBAa
mlr --opprint put $y = gsub($x, "a"i, "Aa") ./reg_test/input/gsub.dat
x y
lmnop lmnop
abcdefg Aabcdefg
ababbabbba AabAabbAabbbAa
LMNOP LMNOP
ABCDEFG AaBCDEFG
ABABBABBBA AaBAaBBAaBBBAa
mlr --opprint put $y = gsub($x, "A"i, "Aa") ./reg_test/input/gsub.dat
x y
lmnop lmnop
abcdefg Aabcdefg
ababbabbba AabAabbAabbbAa
LMNOP LMNOP
ABCDEFG AaBCDEFG
ABABBABBBA AaBAaBBAaBBBAa
================================================================
CHAINING

View file

@ -239,9 +239,9 @@ Functions for filter and put:
abs acos acosh asin asinh atan atan2 atanh cbrt ceil cos cosh erf erfc exp
expm1 floor invqnorm log log10 log1p max min pow qnorm round roundm sin sinh
sqrt tan tanh urand + - - * / % ** =~ !=~ == != > >= < <= && || ! strlen sub
tolower toupper . boolean float int string hexfmt fmtnum systime sec2gmt
gmt2sec sec2hms sec2dhms hms2sec dhms2sec fsec2hms fsec2dhms hms2fsec
dhms2fsec
gsub tolower toupper . boolean float int string hexfmt fmtnum systime
sec2gmt gmt2sec sec2hms sec2dhms hms2sec dhms2sec fsec2hms fsec2dhms
hms2fsec dhms2fsec
Please use "mlr --help-function {function name}" for function-specific help.
Please use "mlr --help-all-functions" or "mlr -f" for help on all functions.
@ -2476,7 +2476,8 @@ urand (math: #args=0): Floating-point numbers on the unit interval. I
|| (boolean: #args=2): Logical OR.
! (boolean: #args=1): Logical negation.
strlen (string: #args=1): String length.
sub (string: #args=3): Example: '$name=sub($name, "old", "new")'. Regexes not supported.
sub (string: #args=3): Example: '$name=sub($name, "old", "new")' (replace once).
gsub (string: #args=3): Example: '$name=gsub($name, "old", "new")' (replace all).
tolower (string: #args=1): Convert string to lowercase.
toupper (string: #args=1): Convert string to uppercase.
. (string: #args=2): String concatenation.