如何在某些模式python中为字符串编写re.split()

时间:2016-11-25 02:52:16

标签: python regex

如何编写re.split()将内容拆分为“.I number”,“。T”,“。A”,“。B”,“。W”??因为我想单独保存内容。

   .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 experimental study of a wing in a propeller slipstream was
    made in order to determine the spanwise distribution of the lift
    increase due to slipstream at different angles of attack of the wing
    and at different free stream to slipstream velocity ratios .  the
    results were intended in part as an evaluation basis for different
    theoretical treatments of this problem .
      the comparative span loading curves, together with
    supporting evidence, showed that a substantial part of the lift increment
    produced by the slipstream was due to a /destalling/ or
    boundary-layer-control effect .  the integrated remaining lift
    increment, after subtracting this destalling lift, was found to agree
    well with a potential flow theory .
      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 .
    in the study of high-speed viscous flow past a two-dimensional body it
    is usually necessary to consider a curved shock wave emitting from the
    nose or leading edge of the body .  consequently, there exists an
    inviscid rotational flow region between the shock wave and the boundary
    layer .  such a situation arises, for instance, in the study of the
    hypersonic viscous flow past a flat plate .  the situation is somewhat
    different from prandtl's classical boundary-layer problem . in prandtl's
    original problem the inviscid free stream outside the boundary layer is
    irrotational while in a hypersonic boundary-layer problem the inviscid
    free stream must be considered as rotational .  the possible effects of
    vorticity have been recently discussed by ferri and libby .  in the
    present paper, the simple shear flow past a flat plate in a fluid of small
    viscosity is investigated .  it can be shown that this problem can again
    be treated by the boundary-layer approximation, the only novel feature
    being that the free stream has a constant vorticity .  the discussion
    here is restricted to two-dimensional incompressible steady flow .

如何编写re.split()将内容拆分为“.I number”,“。T”,“。A”,“。B”,“。W”??因为我想单独保存内容。

2 个答案:

答案 0 :(得分:0)

这几乎就是它,它除了最后一个之外还有所有领域,也许你想知道如何完成它?

请注意,我们需要re.DOTALL,以便.捕获换行符,并使用.*?以便匹配非贪婪。

re.findall("\.I(.*?)\.T(.*?)\.A(.*?)\.B(.*?)\.W(.*?)", s, re.DOTALL)

答案 1 :(得分:0)

 (?:\.I|\.T|\.W|\.A|\.B)(?:(?!(?:\.I|\.T|\.W|\.A|\.B))[\s\S])*

你可以使用它。参见演示。

https://regex101.com/r/9gFcZQ/1