2011-11-30 102 views
0

我想捕捉单词“ABADDON”,直到(不包括ABAFT)。然后我想用“ABAFT”重复这个捕获,直到下一个单词(不包括下一个单词)。这些词是大写的。正则表达式.NET多行捕捉

ABADDON 
A*bad"don, n. Etym: [Heb. abaddon destruction, abyss, fr. abad to be 
lost, to perish.] 

1. The destroyer, or angel of the bottomless pit; -- the same as 
Apollyon and Asmodeus. 

2. Hell; the bottomless pit. [Poetic] 
In all her gates, Abaddon rues Thy bold attempt. Milton. 

ABAFT 
A*baft", prep. Etym: [Pref. a-on + OE. baft, baften, biaften, AS. 
beæftan; be by + æftan behind. See After, Aft, By.] (Naut.) 

Defn: Behind; toward the stern from; as, abaft the wheelhouse. Abaft 
the beam. See under Beam. 
+0

因此,你想捕捉任何大写词之间的东西? – FailedDev

回答

1

很难确切地明白你的意思,但在这里是一个猜测:

(?ms)^([A-Z]+)$(.+?)(?=^[A-Z]+$|\z) 

资本词将是第一个捕获组中,并按照它在第二个文本。

0

起飞上@ Qtax的回答,也可以做这样的:

(?ms)^[A-Z]+$(?:(?!^[A-Z]+$).)*/^[A-Z]+$(?:(?!^[A-Z]+$).)*/ms

采取进一步行动,要宽容到格式化而mantaining一般形式:

(?ms)^[^\S\n]*[A-Z]+\s*$(?:(?!^[^\S\n]*[A-Z]+\s*$).)*

/^[^\S\n]*[A-Z]+\s*$(?:(?!^[^\S\n]*[A-Z]+\s*$).)*/ms