Boost logo

Boost Users :

Subject: Re: [Boost-users] regular expression to extract numbers
From: John Maddock (boost.regex_at_[hidden])
Date: 2012-12-03 04:23:13


> So the first problem I have is defining a correct expression. The pattern
> has the format "sometext>NUMBERS<sometext" newline. The NUMBERS may be one
> or two digits combined and the pattern is repeated 10 times. I have
> searched the archives and tried to build something based on the examples I
> have read, but cannot seem to find a working solution. Can anyone help
> please in defining an expression?

What's wrong with just:

"sometext\\>(\\d{1,2})\\<sometext"

then use a regex_iterator to iterate over all occurances, extracting $1 from
each match.

Even better use regex_token_iterator to spit out each number directly - take
a look at the last example on the bottom of this page:
http://www.boost.org/doc/libs/1_52_0/libs/regex/doc/html/boost_regex/ref/regex_token_iterator.html

HTH, John.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net