Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost.regex expression construction
From: Schrader, Glenn - 1002 - MITLL (gschrad_at_[hidden])
Date: 2010-03-11 11:35:55


Well, you could use something like "[\\(][^\\)]*[\\)]", ie match a left
paren, any number of things that are not a right paren and then a right
paren. Of course, a simple check like this can't detect all the ways is
which the equation can still be incomplete or invalid (e.g. "(2++1)--3"). To
really an truly make sure that the equation is well formed you could use the
boost spirit library (have a look at the calculator example).
--gs

  _____

From: boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]] On Behalf Of Shaolin
Sent: Thursday, March 11, 2010 10:57 AM
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] Boost.regex expression construction

Hello Gevorg,

An example string: (4+1)*2 - I want to return true if the parentheses are
found and false if there are none or there is a partial match ( e.g. (2+2+1
will return false because there is only one parenthese and hence the
equation is incomplete).

Regards

On 11 March 2010 15:43, Gevorg Voskanyan <v_gevorg_at_[hidden]> wrote:

>Shaolin wrote:
>
>>Hi Guys
>
>I am using boost.regex to check whether a string has opening and closing
brackets. The problem is the expression doesnt work. I have tried all sorts
of combos and read up the doc too to no avail. Can someone tell me whether
the following does what its supposed to (i.e. look for opening/closing
brackets in a string):
>
>boost::regex e("[\\(\\)]"); /*check for opening/closing brackets*/
>
>Regards

I'm afraid it's not clear enough what you are trying to match here. Perhaps
you could give us an example of a string which would match the expression?

Regards,
Gevorg

_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users





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