Previous Topic

Next Topic

ReplaceRegEx - MaxBasic Function

ReplaceRegEx(SourceString: String, RegularExpression: String, ReplacementString: String): String

Returns a replaced string based on regular expression.

ReplaceRegEx function syntax has these named arguments:

Parameter

Description

SourceString

Required. The String to be modified.

RegularExpression

Required. The string containing the regular expression.

ReplacementString

The string to replace each match for the RegularExpression.

Sample code:

Dim Transformed as String

' transforms comma separated <link>,<link> into comma separated <a href="link">link</a>

const sourceText = "<http://www.google.com>, <http://www.facebook.com>"

const regex = "<((http://|ftp://|mailto:)[^>]+)>"

const replaceWith = "<a href=""$1"">$1</a>"

Transformed = ReplaceRegEx(sourceText, regex, replaceWith)

Msgbox(Transformed)

Note: For details of the Regular Expression syntax see Regular expressions (RegEx)

See Also

String Functions

Book Contents

Book Index