Tianpu

匹配到的字符作为变量进行下一步匹配,可能一步完成吗?

  •  
  •   Tianpu · Sep 1, 2015 · 2665 views
    This topic created in 4082 days ago, the information mentioned may be changed or developed.
    <block.demo>
    //some more code
    <block.demo>
    
    <block.another>
    //some other more code
    <block.another>
    

    demo,another 是变量
    需要得到 demo,another 这种变量名,还有内包含的块,有一次完成的办法吗?

    谢谢

    2 replies  •  2015-09-01 11:50:12 +08:00
    ligyxy
    ligyxy
    Sep 1, 2015
    1
    小括号
    Tianpu
    Tianpu
    OP
    Sep 1, 2015
    2
    已经解决了,叫做后向引用

    ```
    <block\.([a-z]+)>(.*?)<block\.\1>
    ```
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1985 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 16:34 · PVG 00:34 · LAX 08:34 · JFK 11:34
    ♥ Do have faith in what you're doing.