Questions tagged [boost-regex]

Boost.Regex is a C++ regular expression library with optional Unicode support through ICU.

Boost.Regex is a C++ regular expression library with optional Unicode support through ICU.

296 questions
6
votes
4 answers

How can I use Boost::regex.hpp library in C++?

I tried to use Boost library but I failed, see my code: #include "listy.h" #include using namespace boost; ListyCheck::ListyCheck() { } ListyCheck::~ListyCheck() { } bool ListyCheck::isValidItem(std::string &__item) { …
malhobayyeb
  • 2,725
  • 11
  • 57
  • 91
5
votes
1 answer

boost regular expression capture groups

After a days worth of hacking and reading, I have had no luck with boost's regex engine, hopefully someone here can help. I want to grab the first field out of every line where the last field matching some input. string input = "449 a dingo…
yggdrasil
  • 95
  • 2
  • 7
5
votes
2 answers

How to make group mandatory if other group is found more than once

Here is my regex so far : ^((([a-zA-Z0-9_\/-]+)[ ])+((\bPHONE_NUMBER\b)|(\b(IP|EMAIL)_ADDRESS\b))[ ]*[;]*[ ]*)+$ I would like to make at least one ; mandatory if I found another (([a-zA-Z0-9_\/-]+)[ ])+((\bPHONE_NUMBER\b)|(\b(IP|EMAIL)_ADDRESS\b))…
Roger
  • 657
  • 5
  • 18
5
votes
3 answers

Boost regex and confusing errors

I'm trying to use Boost regex to see if something has an integer in it. One of the examples on this page is bool validate_card_format(const std::string& s) { static const boost::regex e("(\\d{4}[- ]){3}\\d{4}"); return regex_match(s,…
James
  • 2,626
  • 5
  • 37
  • 51
5
votes
1 answer

Why does regex_match throw "complexity exception"?

I am trying to test (using boost::regex) whether a line in a file contains only numeric entries seperated by spaces. I encountered an exception which I do not understand (see below). It would be great if someone could explain why it is thrown. Maybe…
Leolo
  • 416
  • 1
  • 5
  • 12
5
votes
1 answer

When trying to include '#include ' I get: 1>LINK : fatal error LNK1104: cannot open file 'libboost_regex-vc100-mt-gd-1_39.lib'

Not sure why i get that, I downloaded libs from here and while I have a lib called 'libboost_regex-vc90-mt-gd-1_39.lib I don't have one which is called 'libboost_regex-vc100-mt-gd-1_39.lib', renaming the one with vc90 to vc100 works but I'm not sure…
meds
  • 21,699
  • 37
  • 163
  • 314
5
votes
1 answer

Boost regex. Named group in two part

I have problem with boost::regex::regex_match. I work with turned on BOOST_REGEX_MATCH_EXTRA. What I have: (this is a simple example of my problem, not a real task) string input1= "3 4 5"; string input2= "3 4 7"; What I want to get: list output1=…
Darida
  • 196
  • 1
  • 8
4
votes
4 answers

boost::regex segfaults when using capture

I get a seg fault for the simple program below. It seems to be related to the destructor match_results. #include #include #include #include using namespace std; int main(int argc, char *argv) { …
Sam Lee
  • 7,049
  • 10
  • 42
  • 47
4
votes
4 answers

Why does my Boost.Regex search report only one match iteration?

I am trying to find out how many regex matches are in a string. I'm using an iterator to iterate the matches, and and integer to record how many there were. long int before = GetTickCount(); string text; boost::regex…
scottm
  • 27,829
  • 22
  • 107
  • 159
4
votes
3 answers

Getting sub-match_results with boost::regex

Hey, let's say I have this regex: (test[0-9])+ And that I match it against: test1test2test3test0 const bool ret = boost::regex_search(input, what, r); for (size_t i = 0; i < what.size(); ++i) cout << i << ':' << string(what[i]) << "\n"; Now,…
Andreas Bonini
  • 44,018
  • 30
  • 122
  • 156
4
votes
1 answer

boost example failed to build

I'm a newbie about boost. I compiled boost libraries with success (under mac os x). Now, I tried to build the very first example mentioned at boost website (including boost/ as include directory and boost/stage/lib as library directory, with…
Bob
  • 10,741
  • 27
  • 89
  • 143
4
votes
2 answers

Removing unnecessary parentheses in a regular expression

Suppose I have (in a javascript regular expression) ((((A)B)C)D) Of course that really reads ABCD Is there an algorithm to eliminate unnecessary parentheses in a string like that?
Copper
  • 197
  • 2
  • 3
  • 10
3
votes
0 answers

Visual Studios 2010 include Regex Error

I'm trying experiment with regex. So i created a project in VS 2010, and at the top i put: #include "std_lib_facilities.h" #include using namespace std::tr1; int main() { regex rx("123"); cout << ">"; string s; …
Richard
  • 5,840
  • 36
  • 123
  • 208
3
votes
2 answers

Matching binary data using boost regex

Is boost regex able to match binary data in a given binary input? Ex.: Input in binary form: 0x01 0x02 0x03 0x04 0x05 0x01 0x02 0x03 0x04 0x08 Binary expression to match: 0x01 0x02 0x03 0x04 In this case, 2 instances should be matched. Many…
lzuwei
  • 31
  • 2
3
votes
2 answers

boost with icu u32_regex memory leak / cache on Win32

When using the boost regex class with the optional ICU support enabled (see boost documentation for details) I seem to get a memory leak or rather some sort of caching of memory happening which I cannot seem to reset / cleanup. Has anyone else seen…
Alex Perry
  • 335
  • 3
  • 9
1
2
3
19 20