$regsub » History » Version 1
Per Amundsen, 08/13/2015 10:46 AM
1 | 1 | Per Amundsen | _Added in 1.9.0_ |
---|---|---|---|
2 | |||
3 | *$regsub([name], text, re, subtext, %var)* |
||
4 | |||
5 | Performs a regular [[Scripting_Regex|regular expression]] and then performs a substitution using subtext. |
||
6 | |||
7 | Returns the number of substitutions made, and assigns the result to %var. |
||
8 | |||
9 | *Parameters* |
||
10 | |||
11 | [name] - Name of the search, which can later be referenced using [[$regml]]. (optional) |
||
12 | text - The text to search. |
||
13 | re - The [[Scripting_Regex|regular expression]] to perform. |
||
14 | subtext - Subtext to replace with. |
||
15 | %var - Variable to assign the result to. |
||
16 | |||
17 | *Example* |
||
18 | |||
19 | <pre> |
||
20 | alias Example { |
||
21 | var %Example |
||
22 | ; Perform a search for '([O])' and replace it with 'o' and fill the variable %Example with the result. |
||
23 | noop $regsub(name,HellO WOrld,/([O])/g,o,%Example) |
||
24 | echo -a $regml(name,0) : $regml(name,1) -- $regml(name,2) : %Example |
||
25 | } |
||
26 | </pre> |