User guide

24-14
SystemVerilog Testbench Constructs
string str, str1;
str = "SystemVerilog supports postmatch( ) method";
i = str.match("postmatch( )");
str1 = str.postmatch();
This example assigns the value “method” to string str1.
thismatch()
The thismatch() method returns the matched string, based on the
result of the last match() function call. The syntax is:
string string_variable.thismatch();
The following example illustrates the usage of the thismatch() class
method.
integer i;
string str, str1;
str = "SystemVerilog supports thismatch( ) method";
i = str.match("thismatch");
str1 = str.thismatch();
This example assigns the value “thismatch” to string str1.
backref()
The backref() method returns the matched patterns, based on the
last match() function call. The syntax is:
function string string_variable.backref(integer index);
Here, index is the integer number of the Perl expression being
matched. Indexing starts at 0.
This function matches a string with Perl expressions specified in a
second string.