#include "stdafx.h"
using namespace System;
using namespace System::Text::RegularExpressions;
int main()
{
String^ txt="11:Jan:2019 \"This is an Example!\"";
String^ re1="(\\d+)";
String^ re2=".*?";
String^ re3="an";
String^ re4=".*?";
String^ re5="(an)";
Regex^ r = gcnew Regex(re1+re2+re3+re4+re5,RegexOptions::IgnoreCase|RegexOptions::Singleline);
Match^ m = r->Match(txt);
if (m->Success)
{
String^ int1=m->Groups[1]->Captures[0]->ToString();
String^ word1=m->Groups[2]->Captures[0]->ToString();
Console::Write("("+int1->ToString()+")"+"("+word1->ToString()+")"+"\n");
}
Console::ReadLine();
}
|