On Fri, 14 Oct 2005, Dave Adams wrote:

How paragraphs are delimited is actually my question. In otherwords, when perl reads in my string, can it identify where the paragraphs breaks are?

In my example, $text was created in wordpad where 'This is the FIRST paragraph' and 'This is the SECOND paragraph' are seperated by a paragraph break.

My desired output is: This is the FIRST paragraph^PThis is the SECOND paragraph

Thank you for your interest and your efforts to help me out. Very much appreciated.

What's a paragraph break?

I'm familiar with newlines or line breaks (\n), and I'm familiar with carriage returns (\r), but I'm not aware of an ASCII paragraph break.

I *have* seen -- and in fact am using to type this very message -- a convention where two or more newlines delineate paragraph boundaries.
If that fits what you're working on, then you could maybe match

  /\n\s*\n/

or something like that, matching a new line, zero or more spaces (I assume they wouldn't matter), then another newline.


If you want to extend that to the case of the two "or more" newlines, as here, then you need to extend the regex. This might work:

  /\n\s*\n+/

But that doesn't properly check for spaces after the first newline. If that matters, you'll have to tweak it a bit further.

Make sense?


--
Chris Devers

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to