Boost logo

Boost Users :

From: Alan Huang (hygool_at_[hidden])
Date: 2006-02-09 04:19:29


On 1/23/06, Sebastian Redl <sebastian.redl_at_[hidden]> wrote:
>
> Alan Huang wrote:
>
> > Hi,
> >
> > In boost document I saw that the '^' matches all the blank chars in
> > the begin of line and the '$' matches all the blank chars in the end
> > of line. Just like regex( "^abc$" ) can't match the string " abc
> > ". What's wrong?
>
> You misunderstood. ^ doesn't match any characters, it simply fails if
> it's not the start of the line. In other words, it says, "The expression
> after me must match at the start of the line, not simply somewhere." $
> does the same for the end of the line.
> Therefore, "^cde" matches "cdefg", but not "abcde".
>
> If the boost documentation really says that ^ and $ match any blank
> chars, that's a bug and should be corrected.
>
> Sebastian Redl
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>

Thank you Redl,
But I made a expirementation and found that "^cde" couldn't neither match
"cdefg", nor "abcde",
On http://www.boost.org/libs/regex/doc/syntax_perl.html, there are these
words:

 Anchors:

A '^' character shall match the start of a line.

A '$' character shall match the end of a line.
I still can't understand it exactly, if "^cde$" only matches "cde", why we
need to write the regex as "^ced$"?

--
Yours Sincerely,
Alan Huang


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