By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,736 Members | 1,982 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,736 IT Pros & Developers. It's quick & easy.

java.util.regex - combining paragraphs separated by blank line

P: n/a
I need to write a regular expression to group lines of text separated
by a blank line.

Ex.

Input:
line1
line2
line3

line 4
line 5

line 6

I tried turning on the MULTILINE and DOTALL flags and used the
following pattern:
(.+?)^$

which is close but prepends a newline to the 2nd and subsequent calls
to Matcher.find().

The first line of every paragraph is the same, if that helps.

Regex's are cool, but frustrating....
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
David <no**********@nomail.com> wrote in message news:<bl********************************@4ax.com>. ..
I need to write a regular expression to group lines of text separated
by a blank line.

Ex.

Input:
line1
line2
line3

line 4
line 5

line 6

I tried turning on the MULTILINE and DOTALL flags and used the
following pattern:
(.+?)^$

which is close but prepends a newline to the 2nd and subsequent calls
to Matcher.find().

The first line of every paragraph is the same, if that helps.

Regex's are cool, but frustrating....

Regular expression that matches a blank line is ^$
_Mastering Regular Expression_ by Friedl from O'Reilly is a good book.
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.