Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #11350 > unrolled thread

Pattern matching in C++

Started byAlec Taylor <alec.taylor6@gmail.com>
First post2011-11-09 13:20 -0800
Last post2011-11-09 22:08 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.lang.c++


Contents

  Pattern matching in C++ Alec Taylor <alec.taylor6@gmail.com> - 2011-11-09 13:20 -0800
    Re: Pattern matching in C++ Marc <marc.glisse@gmail.com> - 2011-11-09 22:08 +0000

#11350 — Pattern matching in C++

FromAlec Taylor <alec.taylor6@gmail.com>
Date2011-11-09 13:20 -0800
SubjectPattern matching in C++
Message-ID<27659650.209.1320873629242.JavaMail.geo-discussion-forums@prms22>
Good morning,

I'm trying to parse a relatively simple pattern across 4 std::strings, extracting whatever the part which matches the pattern into a separate std::string.

In an abstracted sense, here is what I want:
s1=<string1><consecutive number>, s2=<consecutive number><string2>,
s3=<string1><consecutive number>, s4=<consecutive number><string2>

Less abstracted:
s1="apple 1", s2="2 cheese", s3="apple 3", s4="4 cheese"

Actual contents:
s1="lxckvjlxcjvlkjlkje xvcjxzlvcj wqrej lxvcjz ljvl;x czvouzxvcuj;ljfds apple 1 xcvljxclvjx oueroi xcvzlkjv; zjx",
s2="xzljlkxvcjlkjxzvl jxcvljzx lvjlkj wre 2 cheese",
s3="apple 3",
s4="kxclvj xcvjlxk jcvljxlck jxcvl 4 cheese"

How would I perform this pattern matching, and what libraries should I use?

Thanks for all suggestions,

Alec Taylor

[toc] | [next] | [standalone]


#11351

FromMarc <marc.glisse@gmail.com>
Date2011-11-09 22:08 +0000
Message-ID<j9etlf$pkh$1@news-rocq.inria.fr>
In reply to#11350
Alec Taylor  wrote:

> Good morning,
> 
> I'm trying to parse a relatively simple pattern across 4 std::strings, extracting whatever the part which matches the pattern into a separate std::string.
> 
> In an abstracted sense, here is what I want:
> s1=<string1><consecutive number>, s2=<consecutive number><string2>,
> s3=<string1><consecutive number>, s4=<consecutive number><string2>
> 
> Less abstracted:
> s1="apple 1", s2="2 cheese", s3="apple 3", s4="4 cheese"
> 
> Actual contents:
> s1="lxckvjlxcjvlkjlkje xvcjxzlvcj wqrej lxvcjz ljvl;x czvouzxvcuj;ljfds apple 1 xcvljxclvjx oueroi xcvzlkjv; zjx",
> s2="xzljlkxvcjlkjxzvl jxcvljzx lvjlkj wre 2 cheese",
> s3="apple 3",
> s4="kxclvj xcvjlxk jcvljxlck jxcvl 4 cheese"
> 
> How would I perform this pattern matching, and what libraries should I use?

The standard library should have what you need in <regex>, or if you
have an older compiler/library: Boost.Regex.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.c++


csiph-web