LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-29-2006, 04:21 PM   #1
Centinul
Member
 
Registered: Jun 2005
Distribution: Gentoo
Posts: 552

Rep: Reputation: 30
Examples of PCRE library in C


Anyone have any links or examples of PCRE library usage in C? I've been hunting the net for them and all I can find is documentation on the API itself. It would be helpful to have an example or two. Thanks!
 
Old 08-30-2006, 09:25 AM   #2
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
man pcresample

(well that should have been obvious )

and
 
Old 08-30-2006, 03:06 PM   #3
Centinul
Member
 
Registered: Jun 2005
Distribution: Gentoo
Posts: 552

Original Poster
Rep: Reputation: 30
lol didn't even think of that. Thanks for the link. I've been reading that thing up and down trying to wrap my head around how to use it. I'm just about there. Only one issue left Thanks!

Unfortunately I don't know where the sample file they reference is

Last edited by Centinul; 08-30-2006 at 03:07 PM.
 
Old 08-30-2006, 03:15 PM   #4
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
hmm. i dont know where it would be. a quick search showed that i have it in several places. it looks like the demo comes with php, apache, and also subversion.

if you have the source for any of those it should be in there. otherwise you could just download the pcre source..
 
Old 08-30-2006, 04:59 PM   #5
Centinul
Member
 
Registered: Jun 2005
Distribution: Gentoo
Posts: 552

Original Poster
Rep: Reputation: 30
Ya that's what I figured. Maybe I'll do that. Have you ever used this library?
 
Old 08-30-2006, 05:08 PM   #6
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
only briefly. i was going to use it for some config file parsing, but passed on it. regex was just more than i needed for name value pairs that i had in the config file.
 
Old 08-30-2006, 07:09 PM   #7
Centinul
Member
 
Registered: Jun 2005
Distribution: Gentoo
Posts: 552

Original Poster
Rep: Reputation: 30
It's good to know that someone else has played with it, if I have any questions
 
Old 09-26-2010, 01:07 PM   #8
fakie_flip
Senior Member
 
Registered: Feb 2005
Location: San Antonio, Texas
Distribution: Gentoo Hardened using OpenRC not Systemd
Posts: 1,495

Rep: Reputation: 85
Quote:
Originally Posted by Centinul View Post
lol didn't even think of that. Thanks for the link. I've been reading that thing up and down trying to wrap my head around how to use it. I'm just about there. Only one issue left Thanks!

Unfortunately I don't know where the sample file they reference is
after you do the man pcresample, as he told you to, you see that an example source code file name. Then:

locate pcredemo.c
find / -name pcredemo.c

for me, /usr/share/doc
I like that folder so much I added it to my gnome favorites/bookmarks in nautilus.
 
Old 09-26-2010, 03:19 PM   #9
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by Centinul View Post
Anyone have any links or examples of PCRE library usage in C? I've been hunting the net for them and all I can find is documentation on the API itself. It would be helpful to have an example or two. Thanks!
The library comes with 'pcregrep' - that is, of course, an obvious source of examples.
 
Old 09-26-2010, 05:16 PM   #10
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
I've used the C++ interface.
When I installed the package (on FreeBSD) it came with loads of HTML
documentation. I found it easy to grasp what I needed from it.

see fakie_flip's post eh?

have you checked if you have docs
maybe /usr/share/doc/pcre ?

BTW amazingly it's still not as fast as perl.
I've tried boost::regex, regex and pcre.

Last edited by bigearsbilly; 09-26-2010 at 05:21 PM.
 
Old 09-26-2010, 05:55 PM   #11
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by bigearsbilly View Post
...
BTW amazingly it's still not as fast as perl.
...
Just read comments in Perl proper RE engine - they tried to optimize everything.
 
Old 09-27-2010, 05:13 AM   #12
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
Perl isn't just faster, It actually mashes C++ on regexes.
amazing really. I've done quite a bit of experimenting recently,
started with Boost, then std C libregex then PCRE.

always perl is significantly faster.

mainly using perl splitting into a list compared to C++ splitting into a vector of strings.
(the sort of stuff one needs in the real world)
even cheating in C++ and just printing results without assigning to data structures didn't
beat perl.
it's quite impressive.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
help installing snort: pcre header missing cynthia_thomas Linux - Networking 1 11-07-2005 11:19 AM
PHP: call to undefined function preg_match() (I think to do with PCRE) BuckRogers01 Linux - Software 1 10-17-2005 01:35 PM
PCRE Configuring MDK10 Goryan Linux - Newbie 0 08-21-2004 10:55 AM
Bluefish -> pcre-devel?? p41elvis Linux - Software 3 04-25-2004 11:10 AM
IPTables examples? tarballed Linux - Security 7 12-27-2002 10:07 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration