我有這樣的文字:提取docIDs並從文件的文件並把它們放在一個HashMap
.I 1
.T
experimental investigation of the aerodynamics of a
wing in a slipstream .
.A
brenckman,m.
.B
j. ae. scs. 25, 1958, 324.
.W
experimental investigation of the aerodynamics of a
wing in a slipstream .
an empirical evaluation of the destalling effects was made for
the specific configuration of the experiment .
.I 2
.T
simple shear flow past a flat plate in an incompressible fluid of small
viscosity .
.A
ting-yili
.B
department of aeronautical engineering, rensselaer polytechnic
institute
troy, n.y.
.W
simple shear flow past a flat plate in an incompressible fluid of small
viscosity .the discussion here is restricted to two-dimensional incompressible steady flow .
.I 3
.T
the boundary layer in simple shear flow past a flat plate .
.A
m. b. glauert
.B
department of mathematics, university of manchester, manchester,
england
.W
the boundary layer in simple shear flow past a flat plate .
the boundary-layer equations are presented for steady
flow with no pressure gradient .
我需要一個正則表達式在Java中,這將給如下: 每當GET一個「.I 1」,將給出以「.W」結尾之前的文本。「I 2」
好,現在的問題是:什麼樣的圖案你試過了嗎? –
使用Java,您需要打開MULTILINE模式https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html#MULTILINE 然後,像\ .I之類的東西\ s1。*?\。W(。*?)\。我\ s2應該工作(需要一些轉義)。如果我之後的數字對您很重要,您可能需要添加更多組。或者,由於您匹配的最後一件事似乎是您想要匹配的下一件事的一部分,您可能希望排除它。我傾向於爲這類東西編寫單元測試,然後調整正則表達式直到它工作。也許你可以發佈一些代碼來說明你確切需要什麼? –