lisonfan

求助一个正则的问题

  •  
  •   lisonfan · May 18, 2017 · 2523 views
    This topic created in 3291 days ago, the information mentioned may be changed or developed.

    我要匹配一段内容:

    // Begin
    ....
    ....
    ...
    ..
    ..
    // END
    

    我只想匹配替换

    // Begin
    

    // END
    

    中间的内容

    我写的正则

    \/\/\s*begin\s*([^]+)(?=\/\/\s*end\s*)
    

    由于 JS 不支持前置匹配,所以

    // Begin
    

    不会被保留

    要怎么写才能保留?

    mayl8822
        1
    mayl8822  
       May 18, 2017
    begin([\s\S]*)end
    lisonfan
        2
    lisonfan  
    OP
       May 18, 2017
    @mayl8822 #1 这样写还是会包含 begin end
    mayl8822
        3
    mayl8822  
       May 18, 2017
    取组 1 的内容啊
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3964 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 10:15 · PVG 18:15 · LAX 03:15 · JFK 06:15
    ♥ Do have faith in what you're doing.