473,774 Members | 2,253 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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>expr ession) fails?

Does anyone have any insight into this?

Thanks!
-Velik
Aug 10 '08 #1
4 3394
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>expr ession) 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>expr ession) 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>expr ession) 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>expr ession) 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
7858
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 = re.match("aWbXcXdXeXfY"); >>> print mo1.groupsButNotAsWeKnowIt() ('aW','bX','cX','dX','eX','fY')
4
2182
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 okay is for the actual csv of each log. The second one parses out the description of the log. My problem is with the accesses section of the description. How do I parse multiple groups that have the same name. When I do a for each through the...
0
1026
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 in the named character class specified by {name}. Supported names are Unicode groups and block ranges. For example, Ll, Nd, Z, IsGreek, IsBoxDrawing." I want to know whether those named character classes are predefined or not?
2
5100
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 have to use all the expressions seperately? Here are my regular expressions that check for valid email address and link Dim Expression As String =
4
5187
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 adate LIKE "2004.01.10 __:15") .... into something like this: .... where adate LIKE "2004.01.10 __:(30/15)" ...
4
4404
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 regxCarFile( L"(?=BAR)BAR{2}" ); bRet = boost::regex_search( wstrFilename, m, regxCarFile, boost::match_default ); if( true == bRet )
2
1710
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 based on regular expressions is usually implemented as an alternative of all token definitions. For XPath, a fragment of this expressions looks like this:
1
4386
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 the first regular expression that matches the string. I've gor the regular expressions ordered so that the highest priority is first (if two or more regular expressions match the string I want the first one returned) The code that does this has...
12
2491
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 http://en.wikipedia.org/wiki/Regular_expression http://www.regular-expressions.info/javascript.html http://www.webreference.com/js/column5/
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10264
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10039
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8937
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4012
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.