473,395 Members | 1,471 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Named Group support for regular expressions in TR1?

When I attempt to name a group in a regular expression under TR1, the
library throws a non descriptive error "regular expression error".
The numbered reference group works, as in /1 to reference the first
group. However, any attempt to use (?<myGroup>expression) fails?

Does anyone have any insight into this?

Thanks!
-Velik
Aug 10 '08 #1
4 3365
On Aug 10, 5:21*pm, DomoC...@gmail.com wrote:
When I attempt to name a group in a regular expression under TR1, the
library throws a non descriptive error "regular expression error".
The numbered reference group works, as in /1 to reference the first
group. *However, any attempt to use (?<myGroup>expression) fails?

Does anyone have any insight into this?
How about minimal but complete code (and input) to reproduce the
problem? Compare this FAQ on posting non-working code:

http://www.parashift.com/c++-faq-lit...t.html#faq-5.8

Cheers! --M
Aug 11 '08 #2
On Aug 11, 8:59*am, mlimber <mlim...@gmail.comwrote:
On Aug 10, 5:21*pm, DomoC...@gmail.com wrote:
When I attempt to name a group in a regular expression under TR1, the
library throws a non descriptive error "regular expression error".
The numbered reference group works, as in /1 to reference the first
group. *However, any attempt to use (?<myGroup>expression) fails?
Does anyone have any insight into this?

How about minimal but complete code (and input) to reproduce the
problem? Compare this FAQ on posting non-working code:

http://www.parashift.com/c++-faq-lit...t.html#faq-5.8

Cheers! --M
Certainly...

// Compiler Information
Version 9.0.21022.8 RTM
Microsoft .NET Framework
Version 3.5
Installed Edition: Enterprise
Microsoft Visual C++ 2008 91899-153-0000007-60443
// Operating System
Windows Vista

#include <string>
using std::string;

// This example should be compiled with visual studio 2008, with the
TR1 update
// TR1 Update Link :
http://www.microsoft.com/downloads/d...displaylang=en
#include <regex>
using namespace std::tr1;

int main(int argc, char* argv[])
{
try
{
// this works
regex pattern1( "<[\\?](.+)[\\?]>?" );
// this fails
regex pattern2( "<[\\?](?'groupName'.+)[\\?]>?" );
// so does this
regex pattern3( "<[\\?](?<groupName>.+)[\\?]>?" );
}
catch (std::exception& exc)
{
// shows up as "regular expression error", "unknown (?'groupName')
would have been nice :/ oh well
string dbg = exc.what();
}

return 0;
}
Aug 11 '08 #3
On Aug 11, 7:04*pm, DomoC...@gmail.com wrote:
On Aug 11, 8:59*am, mlimber <mlim...@gmail.comwrote:
On Aug 10, 5:21*pm, DomoC...@gmail.com wrote:
When I attempt to name a group in a regular expression under TR1, the
library throws a non descriptive error "regular expression error".
The numbered reference group works, as in /1 to reference the first
group. *However, any attempt to use (?<myGroup>expression) fails?
Does anyone have any insight into this?
How about minimal but complete code (and input) to reproduce the
problem? Compare this FAQ on posting non-working code:
http://www.parashift.com/c++-faq-lit...t.html#faq-5.8
Cheers! --M

Certainly...

// Compiler Information
Version 9.0.21022.8 RTM
Microsoft .NET Framework
Version 3.5
Installed Edition: Enterprise
Microsoft Visual C++ 2008 * 91899-153-0000007-60443
// Operating System
Windows Vista

#include <string>
using std::string;

// This example should be compiled with visual studio 2008, with the
TR1 update
// TR1 Update Link :http://www.microsoft.com/downloads/d...d=D466226B-8DA...
#include <regex>
using namespace std::tr1;

int main(int argc, char* argv[])
{
* * * * try
* * * * {
* * * * * * * * // this works
* * * * * * * * regex pattern1( "<[\\?](.+)[\\?]>?" );
* * * * * * * * // this fails
* * * * * * * * regex pattern2( "<[\\?](?'groupName'.+)[\\?]>?" );
* * * * * * * * // so does this
* * * * * * * * regex pattern3( "<[\\?](?<groupName>.+)[\\?]>?" );
* * * * }
* * * * catch (std::exception& exc)
* * * * {
* * * * * * * * // shows up as "regular expression error", "unknown (?'groupName')
would have been nice :/ oh well
* * * * * * * * string dbg = exc.what();
* * * * }

* * * * return 0;

}
Looking at the Dinkumware documentation, I don't see support for named
groups in the RE grammar.

http://www.dinkumware.com/manuals/de...lib_regex.html

Am I missing something?

Cheers! --M
Aug 12 '08 #4
On 2008-08-10 17:21:17 -0400, Do******@gmail.com said:
When I attempt to name a group in a regular expression under TR1, the
library throws a non descriptive error "regular expression error".
The numbered reference group works, as in /1 to reference the first
group. However, any attempt to use (?<myGroup>expression) fails?
Named groups are not part of regular expressions in TR1 nor in C++0x.

--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)

Aug 13 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: James Collier | last post by:
Is it possible to capture the results of repeating group matches in the python regular expression module? To illustrate, what I want is: >>> re1 = re.compile("(W)(X)+(Y)"); >>> mo1 =...
4
by: Ben Dewey | last post by:
Hey, I have only been playing with regular expressions for some time. I am working on some code that parses and object 560 event log. I have created two expressions the first one which works...
0
by: Laser Lu | last post by:
Hi, all, Does any body recognize \p{name} in Regular Expression? In MSDN, it says the \p{name} represents a named character class, the original description is as follows: "Matches any character...
2
by: Sehboo | last post by:
Hi, I have several regular expressions that I need to run against documents. Is it possible to combine several expressions in one expression in Regex object. So that it is faster, or will I...
4
by: Együd Csaba | last post by:
Hi All, I'd like to "compress" the following two filter expressions into one - assuming that it makes sense regarding query execution performance. .... where (adate LIKE "2004.01.10 __:30" or...
4
by: DSmith1974 | last post by:
Are lookarounds supported in the boost regex lib? In my VS6 project using boost 1.32.0 I can declare a regex as.. <code_snippet> std::wstring wstrFilename = L"01_BAR08"; boost::wregex...
2
by: Neil Cerutti | last post by:
A found some clues on lexing using the re module in Python in an article by Martin L÷wis. http://www.python.org/community/sigs/retired/parser-sig/towards-standard/ He writes: A scanner...
1
by: Allan Ebdrup | last post by:
I have a dynamic list of regular expressions, the expressions don't change very often but they can change. And I have a single string that I want to match the regular expressions against and find...
12
by: FAQEditor | last post by:
Anybody have any URL's to tutorials and/or references for Regular Expressions? The four I have so far are: http://docs.sun.com/source/816-6408-10/regexp.htm...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.