xiaochong
V2EX  ›  问与答

正则表达式求解

  •  
  •   xiaochong · Aug 17, 2015 · 3070 views
    This topic created in 4097 days ago, the information mentioned may be changed or developed.
    对于如下字符串:

    merge table (t1, t2 ),(t3, t4, t5 ) request node (420001,420002, 420003 )

    希望只匹配 merge table 后括号内容(t1,t2 ),(t3,t4, t5 ), 目前我的书写为

    .*MERGE TABLE\s*(\(.*\))

    结果将 request node 后面括号内容也匹配到了,如何更改表达式来去除, merge table 后括号为 1-n 个

    先谢!
    8 replies  •  2015-08-17 12:26:10 +08:00
    wusuopuBUPT
    wusuopuBUPT
    Aug 17, 2015❤️1
    1
    $pattern = "#merge table (.*?) request#";
    imn1
    imn1
    Aug 17, 2015❤️1
    2
    .*MERGE TABLE\s*(\(.*\)) request
    或
    .*MERGE TABLE\s*(\([^r]*\))
    fising
    fising
    Aug 17, 2015
    3
    @imn1 .*多余
    jiyee
    jiyee
    Aug 17, 2015❤️1
    4
    merge table\s*(.*?)\s*(?=request )
    gangzhuo
    gangzhuo
    Aug 17, 2015❤️1
    5
    imn1
    imn1
    Aug 17, 2015
    6
    @fising
    Y
    照抄,没想
    IFoon
    IFoon
    Aug 17, 2015
    7
    看到头像回复一下。
    xiaochong
    xiaochong
    OP
    Aug 17, 2015
    8
    @IFoon 哈哈
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1705 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 23:40 · PVG 07:40 · LAX 15:40 · JFK 18:40
    ♥ Do have faith in what you're doing.