473,657 Members | 2,624 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unexpected results in matching a regex

#define BOOST_REGEX_DYN _LINK

#include <iostream>
#include <boost\regex.hp p>

using namespace boost;
using namespace std;

int main()
{
regex reg_exp("\xF8.\ x2A..\x0D(P|V)[0-9A-F]{3}");

// I would expect this to match, and it does.
cout << regex_match("\x F8p\x2Aqf\x0DPF FF", reg_exp) << endl;

// I would expect this to *not* match due to the 'w'.
// Why does it match?
cout << regex_match("\x F8p\x2Aqfw\x0DP FFF", reg_exp) << endl;
}
Feb 8 '06 #1
5 2131
Dave wrote:
#define BOOST_REGEX_DYN _LINK

#include <iostream>
#include <boost\regex.hp p>
Should change it to

#include <boost/regex.hpp>

and _never_ again use backslashes in the header name.

using namespace boost;
using namespace std;

int main()
{
regex reg_exp("\xF8.\ x2A..\x0D(P|V)[0-9A-F]{3}");

// I would expect this to match, and it does.
cout << regex_match("\x F8p\x2Aqf\x0DPF FF", reg_exp) << endl;

// I would expect this to *not* match due to the 'w'.
// Why does it match?
cout << regex_match("\x F8p\x2Aqfw\x0DP FFF", reg_exp) << endl;
}


Oh, did you try Boost online forum? What did they say?

V
--
Please remove capital As from my address when replying by mail
Feb 8 '06 #2

"Victor Bazarov" <v.********@com Acast.net> wrote in message
news:_U******** *******@newsrea d1.mlpsca01.us. to.verio.net...
Dave wrote:
#define BOOST_REGEX_DYN _LINK

#include <iostream>
#include <boost\regex.hp p>


Should change it to

#include <boost/regex.hpp>

and _never_ again use backslashes in the header name.

using namespace boost;
using namespace std;

int main()
{
regex reg_exp("\xF8.\ x2A..\x0D(P|V)[0-9A-F]{3}");

// I would expect this to match, and it does.
cout << regex_match("\x F8p\x2Aqf\x0DPF FF", reg_exp) << endl;

// I would expect this to *not* match due to the 'w'.
// Why does it match?
cout << regex_match("\x F8p\x2Aqfw\x0DP FFF", reg_exp) << endl;
}


Oh, did you try Boost online forum? What did they say?

V
--
Please remove capital As from my address when replying by mail


Actually, yes I did post to Boost, but my message has not yet appeared. Your
comment on backslashes contributes absolutely nothing to this thread.
Feb 8 '06 #3
"Dave" <be***********@ yahoo.com> wrote in news:11uk61b2s8 goc61
@news.supernews .com:
#define BOOST_REGEX_DYN _LINK

#include <iostream>
#include <boost\regex.hp p>

using namespace boost;
using namespace std;

int main()
{
regex reg_exp("\xF8.\ x2A..\x0D(P|V)[0-9A-F]{3}");

// I would expect this to match, and it does.
cout << regex_match("\x F8p\x2Aqf\x0DPF FF", reg_exp) << endl;

// I would expect this to *not* match due to the 'w'.
// Why does it match?
cout << regex_match("\x F8p\x2Aqfw\x0DP FFF", reg_exp) << endl;
}


You're asking in the wrong place.... that's not Standard C++. You'll be
much better off asking in the boost user's mailing lists and such.
Feb 8 '06 #4
Dave wrote:
"Victor Bazarov" <v.********@com Acast.net> wrote in message
news:_U******** *******@newsrea d1.mlpsca01.us. to.verio.net...
Dave wrote:
#define BOOST_REGEX_DYN _LINK

#include <iostream>
#include <boost\regex.hp p>
Should change it to

#include <boost/regex.hpp>

and _never_ again use backslashes in the header name.

using namespace boost;
using namespace std;

int main()
{
regex reg_exp("\xF8.\ x2A..\x0D(P|V)[0-9A-F]{3}");

// I would expect this to match, and it does.
cout << regex_match("\x F8p\x2Aqf\x0DPF FF", reg_exp) << endl;

// I would expect this to *not* match due to the 'w'.
// Why does it match?
cout << regex_match("\x F8p\x2Aqfw\x0DP FFF", reg_exp) << endl;
}


Oh, did you try Boost online forum? What did they say?

V
--
Please remove capital As from my address when replying by mail

Actually, yes I did post to Boost, but my message has not yet appeared.


So, you're growing impatient, is that it? Generally, Boost functionality
is OT here. If you asked about std::tr1, you'd be closer to the topic of
this newsgroup.

Have you tried other tools, like Perl or 'sed' to see if the expression is
a match? No, I didn't. I just think that "\x2Aqfw" is not a match for
"\x2A..". You probably wanted to add another dot there.
Your
comment on backslashes contributes absolutely nothing to this thread.


Not true, it promotes healthy coding practices and that is always
a GOOD THING(tm).

V
--
Please remove capital As from my address when replying by mail
Feb 8 '06 #5
Dave wrote:

int main()
{
regex reg_exp("\xF8.\ x2A..\x0D(P|V)[0-9A-F]{3}");

// I would expect this to match, and it does.
cout << regex_match("\x F8p\x2Aqf\x0DPF FF", reg_exp) << endl;

// I would expect this to *not* match due to the 'w'.
// Why does it match?
cout << regex_match("\x F8p\x2Aqfw\x0DP FFF", reg_exp) << endl;
}


I can't speak for the Boost implementation, but our TR1 implementation
gets the same result. It's a little clearer with a slight rewriting of
the regular expression. Yours was:

regex reg_exp("\xF8.\ x2A..\x0D(P|V)[0-9A-F]{3}");

In the ASCII encoding that's equivalent to:

regex reg_exp("\xF8.* ..\x0D(P|V)[0-9A-F]{3}");
And that embedded ".*.." will eat up two or more characters.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Feb 8 '06 #6

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

Similar topics

9
3205
by: Xah Lee | last post by:
# -*- coding: utf-8 -*- # Python # Matching string patterns # # Sometimes you want to know if a string is of # particular pattern. Let's say in your website # you have converted all images files from gif # format to png format. Now you need to change the # html code to use the .png files. So, essentially
3
2745
by: Day Of The Eagle | last post by:
Jeff_Relf wrote: > ...yet you don't even know what RegEx is. > I'm looking at the source code for mono's Regex implementation right now. You can download that source here ( use the class libraries download ). http://www.mono-project.com/Downloads
13
2862
by: Nigel J. Andrews | last post by:
This will be a little vague, it was last night and I can't now do the test in that db (see below) so can't give the exact wording. I seem to remember a report a little while ago about tsearch v2 causing unexpected backend exit messages with 7.3.4 and now I'm getting similar messages unpredictably and I can't find the thread in the archives either. What I did was install tsearch2 using share/contrib/tsearch2.sql, which placed everything...
9
3448
by: Martijn | last post by:
Hi, Which is the prevalent way of matching a filename to a mask in runtime? The best I can think of, is sscanf. Thanks for the help! <OT> It's for the Windows platform, so any functions specific to that platform are welcome too
7
3269
by: Kevin CH | last post by:
Hi, I'm currently running into a confusion on regex and hopefully you guys can clear it up for me. Suppose I have a regular expression (0|(1(01*0)*1))* and two test strings: 110_1011101_ and _101101_1. (The underscores are not part of the string. They are added to show that both string has a substring that matches the pattern.) Applying a match() function on the first string returns true while false for the second. The difference...
8
2234
by: Xah Lee | last post by:
the Python regex documentation is available at: http://xahlee.org/perl-python/python_re-write/lib/module-re.html Note that, i've just made the terms of use clear. Also, can anyone answer what is the precise terms of license of the official python documentation? The official python.org doc site is not clear. Note also, that the regex syntax used by Perl is the same as Python.
0
1539
by: Tidane | last post by:
Visual Basic.NET Framework 2.0 I've created a program to parse out text as the program recieved it and use Regex matching to decide what should be done. My problem is that the text is matching when it shouldn't be, if that makes any sense. If Regex.IsMatch(Text, "You find (a|an)" & MoneyMatch) Then Other code here that doesn't matter. ElseIf Regex.IsMatch(Text, "(+\s)obtains (a|an)") Then More code that doesn't matter. EndIf
6
1494
by: Gary Wardell | last post by:
Hi, I wanted to check if this was correct be behavior before reporting it as a bug in FireFox. Given this function: function test() { var re;
1
3433
by: Joe Strout | last post by:
Wow, this was harder than I thought (at least for a rusty Pythoneer like myself). Here's my stab at an implementation. Remember, the goal is to add a "match" method to Template which works like Template.substitute, but in reverse: given a string, if that string matches the template, then it should return a dictionary mapping each template field to the corresponding value in the given string. Oh, and as one extra feature, I want to...
0
8845
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...
1
8522
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
8622
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
7355
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...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5647
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
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...
0
4333
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1736
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.