ReplaceRegularExpression()

Syntax

Result$ = ReplaceRegularExpression(#RegularExpression, String$, ReplaceString$)
Description
Replaces all strings matching the #RegularExpression with 'ReplaceString$'.

Parameters

#RegularExpression The regular expression to use.
String$ The string to apply the regular expression on.
ReplaceString$ The string to use to replace the matched expression.

Return value

Returns a new string with all matched expressions replaced with 'ReplaceString$'.

Remarks

Back references (usually described as \1, \2, etc.) are not supported. ExtractRegularExpression() combined with ReplaceString() should achieve the requested behaviour.

Example

  ; This expression will match every word of 3 letter which begin by a lower case letter,
  ; followed with the character 'b' and which ends with an uppercase letter. ex: abC
  ;    
  If CreateRegularExpression(0, "[a-z]b[A-Z]")
    Result$ = ReplaceRegularExpression(0, "abC ABc zbA abc", "---")
    Debug Result$ ; Will print "--- ABc --- abc"
  Else
    Debug RegularExpressionError()
  EndIf

See Also

CreateRegularExpression()

Supported OS

All

<- RegularExpressionNamedGroupPosition() - RegularExpression Index