Project

General

Profile

Actions

$regsub » History » Revision 1

Revision 1/6 | Next »
Per Amundsen, 08/13/2015 10:46 AM


Added in 1.9.0

$regsub([name], text, re, subtext, %var)

Performs a regular regular expression and then performs a substitution using subtext.

Returns the number of substitutions made, and assigns the result to %var.

Parameters

[name] - Name of the search, which can later be referenced using $regml. (optional)
text - The text to search.
re - The regular expression to perform.
subtext - Subtext to replace with.
%var - Variable to assign the result to.

Example

alias Example {
  var %Example
  ; Perform a search for '([O])' and replace it with 'o' and fill the variable %Example with the result.
  noop $regsub(name,HellO WOrld,/([O])/g,o,%Example)
  echo -a $regml(name,0) : $regml(name,1) -- $regml(name,2) : %Example
}

Updated by Per Amundsen over 9 years ago · 1 revisions

Also available in: PDF HTML TXT