Substitute - cRegEx
Replaces the first match 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 Substitute String sSubject String sReplacement Returns String
Call Example
Get Substitute sSubject sReplacement to StringVariable
Description
Replaces the first match in the subject string.
Returns a string with the first full match 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 the first number in the string bold.
Handle hoRegEx
String sHtml
Get Create (RefClass(cRegEx)) to hoRegEx
Set psExpression of hoRegEx to "\d+([.,]\d+)?"
Get Substitute of hoRegEx "20 x 59,99 = 1199,8" "<b>$0</b>" to sHtml
Send Destroy of hoRegEx
The result in sHtml will be
"<b>20</b> x 59,99 = 1199,8"
Return Value
String with the first full match in the subject and replaced with the replacement string.