Equinox Online Help - Language Reference - A to Z

Home

Replace

Applies to
SyntaxReplace StringItem, SearchExpression, NewExpression [, OccurrencesExpression]
Action[Statement] Replaces segments within a string.
ScopeUsable anywhere.
Notes

This statement searches for instances of the sub-string SearchExpression within StringItem. When an occurrence of SearchExpression is found, it is replaced with NewExpression.

The optional argument, OccurrencesExpression, determines how many times the statement searches for SearchExpression. If you omit OccurrencesExpression, then every instance of SearchExpression is replaced.

After the statement, the SysReply system workarea is set to the number of replacements that were made.

CategoryString handling
See Also ChrList, Chrs, Compare, Fill, IsNumber, Left_Function, Len, Match, Maxlen, Mid_Function, Remove, Replace, Right_Function], Search_SearchNext, SetLen, SetMaxLen, SortOrder, SubstituteData
Example

The following example searches (through the string txt) for instances of the string "MR" and replaces them with "Mr".

Replace txt, "MR", "Mr"

The next example searches for one occurrence of the string oldstr and replaces it with newstr.

Replace txt, oldstr, newstr, 1