Skip to content

SubstituteAll - cRegEx

Replaces all matches in the subject string

Type: Function
Return Data Type: String

Parameters

Parameter Type Description
sSubject String The host string to search and replace in
sReplacement String The host to replace each match with

Syntax

Function SubstituteAll String sSubject String sReplacement Returns String

Call Example

Get SubstituteAll sSubject sReplacement to StringVariable

Description

Replaces all matches in the subject string.

Returns a string with the all full matches in the subject and replaced with the replacement string. Match values can be used in the replacement string using $0 (full match, $1 for group 1, ${foo} for group foo).

Sample

The sample below makes all the numbers in the string bold.

Handle hoRegEx 
String sHtml 

Get Create (RefClass(cRegEx)) to hoRegEx 
Set psExpression of hoRegEx to "\d+([.,]\d+)?" 
Get SubstituteAll of hoRegEx "20 x 59,99 = 1199,8" "<b>$0</b>" to sHtml 

Send Destroy of hoRegEx

The result in sHtml will be

"20 x 59,99 = 1199,8" "<b>$0</b>"

Return Value

String with the all full matches in the subject and replaced with the replacement string