How can I capture a multiline pattern using a regular expressions in java?
Posted
by
lampShade
on Stack Overflow
See other posts from Stack Overflow
or by lampShade
Published on 2011-03-03T03:31:34Z
Indexed on
2011/03/03
7:24 UTC
Read the original article
Hit count: 235
I have a text file that I need to parse using regular expressions. The text that I need to capture is in multiline groups like this:
truck
zDoug
Doug's house
(123) 456-7890
[email protected]
30
61234.56
8/10/2003
vehicle
eRob
Rob's house
(987) 654-3210
[email protected]
For this example I need to capture truck followed by the next seven lines.In other words, in this "block" I have 8 groups. This is what I've tried but it will not capture the next line:
(truck)\n(\w).
NOTE: I'm using the program RegExr to test my regex before I port it to Java.
© Stack Overflow or respective owner