I’m using System::Text::RegularExpressions::Regex to try and find a startup message in a log file. My expression is as follows:
using namespace System::Text::RegularExpressions;
Regex^ logStartRegex = gcnew Regex( "^=+ .* \\((\\d+)/(\\d+)/(\\d+) @ (\\d+):(\\d+):(\\d+)\\) (.*) =+", static_cast<RegexOptions>(RegexOptions::Compiled | RegexOptions::IgnoreCase) );
…and my test data is:
========= Logging started (07/10/2011 @ 15:38:54) v1.000 AA000 =========
…but when I do the following I don’t get a match:
logStartRegex->Match( "========= Logging started (07/10/2011 @ 15:38:54) v1.000 AA000 =========\n" );
I’ve tested it in regexpal which indicates it works (note that in the C++ version we have to escape all the ‘\’ characters): ^=+ .* \((\d+)/(\d+)/(\d+) @ (\d+):(\d+):(\d+)\) (.*) =+. Is there any way to see where exactly this is breaking down?
I just tried the following program, copied from what you provided:
It writes out
Trueto the screen, meaning that it found a match. So I suppose the problem must be somewhere else in your program.