ReplaceText
jdubs edited this page Oct 21, 2016
·
1 revision
Locates and replaces text in variable supplied.
SpecName (constant) The variable containing the text to search.
OldCharacter (multiple) The value containing the character to find and replace.
NewCharacter (multiple | optional) The value containing the character for replacement. If value is empty the text will simply be removed.
ErrorMessage (multiple | optional) The error message to return when any error occurs.
This method searches the variable for the supplied text, and upon discovery replaces with the supplied new value. For example, a NewCharacter of "6" and an old character of "4" applied to the value "747" would result in "767".
public static void ReplaceText(string SpecName, object OldCharacter, object NewCharacter, object ErrorMessage)
{
Break();
try
{
Variable(SpecName).Value = Variable(SpecName).Value.Replace((string)OldCharacter, (string)NewCharacter);
}
catch (Exception ex)
{
throw new Four51ActionsException(ex.Message, (string)ErrorMessage);
}
}