pcre example to match an empty line

R

Ram Prasad

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
 
S

Seebs

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
 
B

Ben Bacarisse

Ram Prasad said:
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.
 

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,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top