Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > pcre example to match an empty line

Reply
Thread Tools

pcre example to match an empty line

 
 
Ram Prasad
Guest
Posts: n/a
 
      04-14-2011
I have a script to match for the first blank line in the file

I am trying to use a pcre pattern like '^\s*$' but this doesnt work
Can someone please find where the code is wrong

The code is here
http://pastebin.com/Xap9dUWt
 
Reply With Quote
 
 
 
 
Seebs
Guest
Posts: n/a
 
      04-14-2011
On 2011-04-14, Ram Prasad <(E-Mail Removed)> wrote:
> I have a script to match for the first blank line in the file


A "script"?

> I am trying to use a pcre pattern like '^\s*$' but this doesnt work
> Can someone please find where the code is wrong


This question does not visibly have anything to do with the C language.

Please read this:

http://www.catb.org/~esr/faqs/smart-questions.html

Then, once you've thought that through, try asking your question intelligibly
and in the appropriate place, which is very unlikely to be comp.lang.c.

-s
--
Copyright 2011, all wrongs reversed. Peter Seebach / http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
 
Reply With Quote
 
 
 
 
Ben Bacarisse
Guest
Posts: n/a
 
      04-14-2011
Ram Prasad <(E-Mail Removed)> writes:

> I have a script to match for the first blank line in the file
>
> I am trying to use a pcre pattern like '^\s*$' but this doesnt work
> Can someone please find where the code is wrong
>
> The code is here
> http://pastebin.com/Xap9dUWt


The problem is not a C one, but since I can't suggest the right group to
ask libpcre questions in, I'll venture an answer.

You clip the newline off the string (by the way, you should check that
the last character of the string really is a newline) but you don't tell
pcre_exec that the string is now one character shorter. I.e. you must
pass n-1 not n to pcre_exec.

--
Ben.
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
about pcre regex lib mainland C Programming 16 07-22-2006 06:18 PM
Regular expressions: string substitution with pcre or any other library? Bernd Muent C++ 2 02-15-2006 01:31 PM
pcre.c : And Operator sgane2001@yahoo.co.in C Programming 17 02-19-2005 08:12 PM
can you help a new pcre user??? news C Programming 3 07-02-2004 02:29 AM
$match = true() for empty $match?? Victor XML 2 05-17-2004 10:43 AM



Advertisments