Boost logo

Boost Users :

Subject: [Boost-users] [Spirit-general] Pattern matching with boost
From: Alec Taylor (alec.taylor6_at_[hidden])
Date: 2011-11-12 09:13:56


Thank you all for your replies, I can see that each have been
carefully though out and well documented

:)

Tkil: With new concepts such as this, I often have trouble explaining
myself. This is the exact same problem as the initial one, merely with
a simpler explanation.

My current thinking sees what I am doing as being outside the scope of
regex, so I am planning to address the problem using just standard
C++.

Problem[1]
- Compare 3 strings of text, if follows pattern[2] return
s1.substr(text1+number) else return ""

[2] Pattern is:
s1.substr(text1+number)==s2.substr(text1+number-2)==s3.substr(text1+number-4)

std::string answer=analyse(std::string("He ode 1"), std::string("Ze
ode 3zczvsfd"), std::string("e ode 5"));

So in this case the answer would equate to: "e ode 1"

It seems to me that the only way to do this would be:
1. Search the 3 std::string for number, store number, length of number
and position in a data-structure
2. Check if number in s1 == 2-number in s2 == 4-number in s3
3. If it does, find and the Longest Common Substring which includes
the number, return the s1.substr LCS found
4. Else return ""

I am thinking to piece this together using just the stdlib
(std::isdigit &etc)... what do you think?

Thanks for all suggestions,

Alec Taylor

[1]: Note that this is the same problem as my initial one stated, but
I think this time I have figured out a completely unambiguous method
of explaining both the pattern, input data, and expected results.


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