The following code example uses regular expressions to look for exact substring matches. The search is performed by the static
Example
В | ![]() |
---|---|
// regex_simple.cpp // compile with: /clr #using <System.dll> using namespace System; using namespace System::Text::RegularExpressions; int main() { array<String^>^ sentence = { "cow over the moon", "Betsy the Cow", "cowering in the corner", "no match here" }; String^ matchStr = "cow"; for (int i=0; i<sentence->Length; i++) { Console::Write( "{0,24}", sentence[i] ); if ( Regex::IsMatch( sentence[i], matchStr, RegexOptions::IgnoreCase ) ) Console::WriteLine(" (match for '{0}' found)", matchStr); else Console::WriteLine(""); } return 0; } |