perl-like regular expression parsing for C++

B

Bill Chiu

Hi:

I'm used to perl's regular expression string matching, e.g.

if ($line =~ /^(.*)[ \t]+(.*)$/) {
$name = $1;
$age = $2;
....

I want to do this in C++ using gcc under linux and cygwin - what would
a good solution look like?

Mr. B
 
N

Noah Roberts

Bill said:
Hi:

I'm used to perl's regular expression string matching, e.g.

if ($line =~ /^(.*)[ \t]+(.*)$/) {
$name = $1;
$age = $2;
...

I want to do this in C++ using gcc under linux and cygwin - what would
a good solution look like?

It would look like a third party library probably found on freshmeat.

NR
 
R

Ron Natalie

Bill Chiu said:
Hi:

I'm used to perl's regular expression string matching, e.g.

if ($line =~ /^(.*)[ \t]+(.*)$/) {
$name = $1;
$age = $2;
..

The standard library doesn't help, but there are some good regular expression
classes out there including the one in boost (http://www.boost.org).
 
J

Jon Bell

Bill said:
I'm used to perl's regular expression string matching, e.g. [snip]
I want to do this in C++ using gcc under linux and cygwin - what would
a good solution look like?

It would look like a third party library probably found on freshmeat.

A Google search on "C++ regular expression library" turns up some
candidates.
 
U

Uwe Schnitker

Ron Natalie said:
Bill Chiu said:
Hi:

I'm used to perl's regular expression string matching, e.g.

if ($line =~ /^(.*)[ \t]+(.*)$/) {
$name = $1;
$age = $2;
..

The standard library doesn't help, but there are some good regular expression
classes out there including the one in boost (http://www.boost.org).

One nice thing - among others - about the boost regex library is that
something quite similiar has been voted to go into the forthcoming
Library Technical Report, which is the first step to become part
of the next revision of the C++ standard.

It will take several years until this revision will become official, but
hopefully compiler and library providers will include them when it will be
inofficially decided.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top