Go to: Synopsis. Return value. Related. MEL examples.

Synopsis

substitute string string string

substitute is NOT undoable, NOT queryable, and NOT editable.

Finds the portion of the second argument, the input string, that matches the regular expression in the first argument and replaces it with the string in the third argument. If there is no match between the input string and the regular expression then the original string is returned unaltered.

For a more detailed description of how to use regular expressions, see the documentation for the match command.

Return value

stringSubstituted string

Related

match

MEL examples

string $test = "Hello -%there%-";
string $regularExpr = "-%.*%-";
string $s1 = `substitute $regularExpr $test "Mel"`;
// Result: Hello Mel //
string $s2 = `substitute "foo" $test "Mel"`;
// Result: Hello -%there%- //

// The string $s1 will contain "Hello Mel" and the string $s2 will
// contain "Hello -%there%-".