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
1
vote
1 answer

How to truncate a string given an expression using boost

I need to truncate a string after an underscore. Example:- std::wstring name = L"Steve_Smith"; trim_right_if(name, is_any_of(L"_")); The trim_right_if is not working, the name remains the same after its execution. Is there a way using boost::regex…
1
vote
1 answer

What is the use of "!" mark in perl regular expression?

I'm using the boost library for regular expression. What is the use of "!" mark in the Perl regular expression? What does it denote?
BSalunke
  • 11,499
  • 8
  • 34
  • 68
1
vote
1 answer

boost regex and ifstream

Is there a way to use the regex class of boost to search in a file without completely reading it into memory? I currently read a file per line and this makes the parsing quite complicate compared to searching via regex. I do it per line because the…
nobs
  • 708
  • 6
  • 25
1
vote
2 answers

compiling simple code with boost::regex

I'm having trouble compiling the following code: #include #include #include using namespace std; int main() { string s; boost::regex re("^{(APPLE|ORANGE),(\\d*)}$"); boost::cmatch matches; …
user1526533
  • 441
  • 1
  • 5
  • 9
1
vote
2 answers

Regular expression with a small bug

I have this string hey {Bobby|Apple|Peter}, nice to meet you {David} and this regex: (\{(\w+)(\|(\w+))*)\} the answer: Bobby Peter David However, it's not getting "Apple", how can I fix this to get it as well? Thanks!
unwise guy
  • 1,048
  • 8
  • 18
  • 27
1
vote
2 answers

Regular Expressions in C++ using Boost

So far.. I have this test string: Hello {John|Paul|Cindy}, hows {david}? and my expression is: (\{\w+\}) However, it only returns david. I want to be able to grab John, Paul, and Cindy. There would only be 0 or 2 vertical bars. any ideas? Thanks
unwise guy
  • 1,048
  • 8
  • 18
  • 27
1
vote
2 answers

How to grab a string using boost::regex in C++?

example string: std::string sentence = "Hello {Bobby}, hows {Johns}?." I want to be able to grab everything inside the curly braces using boost::regex, any help or guidance would be appreciated. the string can contain {bobby|john|cindy} or…
unwise guy
  • 1,048
  • 8
  • 18
  • 27
1
vote
1 answer

How can I find position in string for submatch in boost::regex

after boost::regex_search(start, end, what, pattern) I can find start position of full match in search string by calling what.position(). How can I find those positions for submatches? I need to have code like this: if(boost::regex_search(start,…
Trisch
  • 138
  • 10
1
vote
1 answer

How to write these regular expression in c++ boost?

I want to do two replacement in a string, and i know how to write the regex in php, curently i am not familiar with c++ boost. // Replace all doubled-up
tags with

tags, and remove fonts. $string = preg_replace("/[…

luyi0619
  • 313
  • 3
  • 8
0
votes
2 answers

Tokenising text using boost regex

I forget regular expressions faster then my mothers birthday. It is a major PITA. Anyhow I wanted a RE for parsing the HTTP response status line and have the sub-elements properly captured. I got this working : const boost::regex…
Hassan Syed
  • 20,075
  • 11
  • 87
  • 171
0
votes
1 answer

Get tags of the same level?

Boost throws an exception. An unhandled exception "0x000007fefd0aa88d" in the "svg.exe": Exception Microsoft C: boost :: exception_detail :: clone_impl > for the regular…
manking
  • 396
  • 1
  • 6
  • 21
0
votes
1 answer

Why do I get a coredump when I try to catch an exception from boost::regex_match(text, e)?

The following example is from the tutorial. When I run it, it throws exception and then coredump. I try to use catch() to catch the exception to avoid coredump like the following: But it doesn't work. any suggestions? Thanks -Todd ---- coredump…
user1273456
  • 71
  • 1
  • 3
0
votes
2 answers

Removing C/C++ style comments using boost::regex

I'm attempting to remove C and C++ style comments from a string using a regular expression. I have found one for Perl that seems to do…
nerozehl
  • 463
  • 1
  • 7
  • 19
0
votes
1 answer

Need help regarding creating a Regex for email id match

I am very new to regex and need help. I am looking for a regex which matches only if any of 3 email ids are found in the message headers (lets say a@gmail.com, b@gmail.com and c@rediffmail.com) if there is any email id in sender header then it…
0
votes
1 answer

How to write a regexp with AND operator?

I have definition string from my user to match an input string and i would like to simplify the definition string so my user won't need to know regexp internal. my thought was to allow */-7721/-7722/-7723 to match any given 4 digit string which is…
NirMH
  • 4,769
  • 3
  • 44
  • 69