Boost logo

Boost Users :

From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2006-07-25 03:13:14


Winson,

Please take a look at the regex character class names at:

http://www.boost.org/libs/regex/doc/syntax_perl.html

And especially at:
http://www.boost.org/libs/regex/doc/character_class_names.html

At the second location is written that [[:space:]] char class name is:
"Any whitespace character."

For [[:blank:]] is written:
"Any whitespace character that is not a line separator."

So space includes line separators

At the first location URL is stated:
"Escape sequence Equivalent to
 \s [[:space:]]"

So using \s or [[:space:]] will consider line breaks.

Now to the partial expression:
Net income per common share:?

This will not work as desired since '?' states only for the colon zero or
more times to be matched, all other words must be there once.

Please read from the first location URL about Perl Extended Patterns,
especially:
"Non-marking grouping
(?:pattern) lexically groups pattern, without generating an additional
sub-expression."

So in your case you need to write:
(?:Net income per common share:)?

Non-marking grouping should be used, because you are not interested in
remembering this pattern, but would like to ensure, that this pattern is
there 0 or more times.

With Kind Regards,
Ovanes Markarian

>I am trying to match (case insenstive) the following two lines with a
>single regular expression, but somehow it doesn't work using boot
>regex:
>
>NET INCOME PER COMMON SHARE:
> Basic .................................................. $
>4.38 $ 3.90 $ 3.37
>
>where:
>1) there might be spaces before "NET INCOME PER COMMON SHARE"
>2) there might be spaces after "NET INCOME PER COMMON SHARE"
>3) the semicolon might be optional
>
>^(\\s*)?Net income per common share:?(\\s*)?\\r\\n( *)?basic
>
>Any one has suggestions?
>
>/Winson


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