From a9f641a6ec9d70ab4d78f6280ede0d5e64c3d50c Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 29 Apr 2023 15:21:32 +0300 Subject: [#strings/glsub] Added documentation --- awk-edits/#strings.awk | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'awk-edits/#strings.awk') diff --git a/awk-edits/#strings.awk b/awk-edits/#strings.awk index 5e486bb..3365df2 100644 --- a/awk-edits/#strings.awk +++ b/awk-edits/#strings.awk @@ -44,8 +44,14 @@ function gesub(regexp, exregexp, replacement, target) { return result target; } -# glsub(lbregexp, regexp, largexp, replacement [, empt, target]) +# glsub(lbregexp, regexp, largexp, replacement [, target]) # Aka global sub with non-capturing look-around (lookbehind and lookahead) +# Behaves kind of like gsub, however substitution of regexp with replacement +# only happens, when regexp is preceded by lbregexp and succeeded by laregexp. +# Only regexp get's replaced, the matches of lbregexp and laregexp are left +# as-is. Overlapping of any form isn't supported. +# This function is quite slow, try to use as little as possible. +# Returns the result string, rather than doing it inplace. function glsub(lbregexp, regexp, laregexp, replacement, target) { if (!length(target)) { target = $0; -- cgit v1.3.1-26-gb76a