tr1::regex
-
I need a quick example on how to use tr1::regex class from VS2008. I have a string like "something" "something" ... and I want to get only what's between the first quotes. In VC6 find/replace it would look Find: "\([^"]\)" Replace: \1
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal
-
I need a quick example on how to use tr1::regex class from VS2008. I have a string like "something" "something" ... and I want to get only what's between the first quotes. In VC6 find/replace it would look Find: "\([^"]\)" Replace: \1
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal
Try Namespace:
System::Text::RegularExpressions
#using <System.dll>
using namespace System;
using namespace System::Text::RegularExpressions;
int main()
{Regex^ rx = gcnew Regex( "\\b(?<word>\\w+)\\s+(\\k<word>)\\b",static_cast<RegexOptions>(RegexOptions::Compiled | RegexOptions::IgnoreCase) );
String^ text = ""something" "something"";
MatchCollection^ matches = rx->Matches( text );
Console::WriteLine( "{0} matches found.", matches->Count );for each (Match^ match in matches)
{
String^ word = match->Groups["word"]->Value;
int index = match->Index;
Console::WriteLine("{0} repeated at position {1}", word, index);
}
}http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx[^]
-
Try Namespace:
System::Text::RegularExpressions
#using <System.dll>
using namespace System;
using namespace System::Text::RegularExpressions;
int main()
{Regex^ rx = gcnew Regex( "\\b(?<word>\\w+)\\s+(\\k<word>)\\b",static_cast<RegexOptions>(RegexOptions::Compiled | RegexOptions::IgnoreCase) );
String^ text = ""something" "something"";
MatchCollection^ matches = rx->Matches( text );
Console::WriteLine( "{0} matches found.", matches->Count );for each (Match^ match in matches)
{
String^ word = match->Groups["word"]->Value;
int index = match->Index;
Console::WriteLine("{0} repeated at position {1}", word, index);
}
}http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx[^]
-
I need a quick example on how to use tr1::regex class from VS2008. I have a string like "something" "something" ... and I want to get only what's between the first quotes. In VC6 find/replace it would look Find: "\([^"]\)" Replace: \1
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal