User guide
24-13
SystemVerilog Testbench Constructs
integer i;
string str;
str = "SystemVerilog supports match( ) method";
i = str.match("mat");
This example assigns the value 1 to integer i because the pattern
“mat” exists within the string str.
prematch()
The prematch() method returns the string that is located just before
the string found by the last match() function call. The syntax is:
string string_variable.prematch();
The following example illustrates the usage of the prematch() class
method.
integer i;
string str, str1;
str = "SystemVerilog supports prematch( ) method";
i = str.match("supports");
str1 = str.prematch();
This example assigns the value “SystemVerilog” to string str1.
postmatch()
The postmatch() method returns the string that is located just after
the string found by the last match() function call. The syntax is:
string string_variable.postmatch();
The following example illustrates the usage of postmatch() class
method.
integer i;