Boost logo

Boost Users :

Subject: Re: [Boost-users] [Spirit-general] Pattern matching with boost
From: Alec Taylor (alec.taylor6_at_[hidden])
Date: 2011-11-09 23:40:30


I have a larger code-base, in which I have restricted possible matches
to 4 std::string.

Basically all I know is there MIGHT exists a name1 with form
name1->number1, in s1 where name1 == name1 in s3 where s3 contains
name1->number1+2.

Perhaps look at a s5 (number1+4) to confirm pattern.

IF a pattern like this exists, return s1.substr(<whatever the mathed area is>)

(sorry if I didn't explain this clearer before)

How would I do this in boost?

Thanks for all suggestions,

Alec Taylor

On Thu, Nov 10, 2011 at 3:33 PM, Anthony Foiani <tkil_at_[hidden]> wrote:
> Alec Taylor <alec.taylor6_at_[hidden]> writes:
>
>> Would it be possible to abstract away the terms "apple" and "cheese"
>> to just equal anything with that pattern?
>>
>> So like this:
>>
>> s1=name1-> consecutive-number
>> s2= consecutive-number->name2
>> s3=name1->consecutive-number
>> s4=consecutive-number->name2
>
> Just what pattern do you mean, though?  You've used "name" and
> "string1".  Is there a character class or other short regexp that
> would match what you mean by "name" below?
>
> And do you already have the 4 strings, or are you scanning a
> continuous piece of text?  If the latter, you're suddenly in the realm
> of wanting a state machine (because if s4 fails to match, then might
> have to consider s3 the new s1 and s4 the new s2...)
>
> Is "consecutive" only within the 4 strings, or is it actually
> cumulative from some other value?  (This is a big part of what makes
> this difficult to do with boost or any other C/C++-based RE engine.
> Perl allows one to actually do evaluation within the search string, so
> you really could match this all with a single RE there -- but it'd be
> ugly, and I don't really know how efficient it would be.)
>
> Curious,
> T.
>


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