You are here

Testcomplete regular expression replace string working example

This little exampel is a demo of how to use regular expressions within a TestComplete Javascript.
In the string "str", is soem XML example. I desire to substitute the tag and value, with an "Ingored" tag.

function RegExReplaceDemo()
// The String
var str = "<SomeXMLNode>f44a944b-eab6-45af-91fa-5717f654</SomeXMLNode>";
// The regular expression for replacement identification
var re = /SomeXMLNode.*de/gi;
// The string replacing
str = str.replace(re, "/Ingnored");


A link to further infomation about using regular expressions in TestComplete is here: