cyocum has asked for the wisdom of the Perl Monks concerning the following question:
Oh great and wise monks,
I have been working on a couple of example uses for perl in the humanities. See this node for some background information. I have run into a problem however that I hope you can help me solve.
I was going to show them how to parse up some of the information in the Annals of Ulster. For example,
U448.1\n \n Several walls of the imperial city of Constantinople which had been fr +eshly\n rebuilt with masonry, and fifty-seven towers collapsed as a result of +a\n violent earthquake which prevailed in various places.\n \n U483.2\n \n Or, this year the battle of Ocha according to others, won by Muirchert +ach\n Mac Erca and by Fergus Cerball son of Conall of Cremthann, and by Fiac +hra\n Lon son of the king of Dal nAraide.\n \n
Now as you can see, it always starts with the letter 'U', which is a good thing to anchor the regex. Then it has two \n another good solid thing. Then I run into problems because the lines of text for a paragraph are broken up by single \n then it ends with two \n. So I come up with a regex something like this:
/U(\d+\.\d+)\n{2}(.+)\n{2}/
The problem is that if I use the regex modifier /s it is completely greedy and matches everything rather than just things between the two \n\n delimiters. What I would like is a regex that matches multiple lines including single \n but stops when it gets to \n\n. I am sure that I am missing something simple but I cannot think of it right now and humbily beseech your wisdom on the topic.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex Question
by tachyon (Chancellor) on Apr 11, 2004 at 12:23 UTC | |
|
Re: Regex Question
by borisz (Canon) on Apr 11, 2004 at 12:23 UTC | |
by tachyon (Chancellor) on Apr 11, 2004 at 12:37 UTC | |
|
Re: Regex Question
by Aragorn (Curate) on Apr 11, 2004 at 22:50 UTC | |
|
Re: Regex Question
by cyocum (Curate) on Apr 11, 2004 at 12:46 UTC |