$regsub: Difference between revisions

From Scriptwiki
Jump to navigation Jump to search
m added null page
 
m one less typo
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
'''$regsub([name], text, re, subtext, %var)'''
Performs a regular expression match, like [[$regex|$regex()]], and then performs a substitution using subtext.<br />
Returns N, the number of substitutions made, and assigns the result to %var.
Example:
alias testing {
  var %num_of_matches = $regsub(a dog was eating milk,/dog/g,cat,%new_content)
  ;%num_of_matches will have a value of 1, since 'dog' was matched once
  ;%new_content will be 'a cat was eating milk'
}
[[Category:Regular_Expression]]
[[Category:Regular_Expression]]
[[Category:Identifiers]]

Latest revision as of 20:26, 12 July 2013

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

Performs a regular expression match, like $regex(), and then performs a substitution using subtext.
Returns N, the number of substitutions made, and assigns the result to %var.

Example:

alias testing {
 var %num_of_matches = $regsub(a dog was eating milk,/dog/g,cat,%new_content)
 ;%num_of_matches will have a value of 1, since 'dog' was matched once
 ;%new_content will be 'a cat was eating milk'
}