星际争霸重播正则表达,支持麻烦

时间:2011-05-20 03:18:44

标签: regex rss yahoo yahoo-pipes

[2v2] race = [TPvZP] map = [Monlyth Ridge]球员= [球员1(T)(w),球员2(P)(L)vs球员3(Z)(W),球员4(P) (W)]长度= [00-10-06]

在Starcraft网站上为TheLittleOne(专业玩家)工作,我很难找到以下情况的正则表达式。 [括号导致正则表达式变长。

我想要以下蜇伤 例如) 游戏类型:2v2 比赛:TPvZP 地图:Monlyth Ridge PLAYER1:名称 Player2:名称 Player3:名称 Player4:名称 Player1-4:比赛(P,T,Z,R) 球员1-4:胜利(W,L) 游戏时长:10分6秒。

我搜索了S.O.好几天我似乎无法找到解决方案。

1 个答案:

答案 0 :(得分:2)

给定字符串[2v2] race=[TPvZP] map=[Monlyth Ridge] players=[player 1(T)(w), player 2(P)(L) vs player3(Z)(W), player4(P)(W)] Length=[00-10-06]

~ ((\w*) \s*=\s*)? \[(.*?)\] ~ msx将产生以下内容:

"" => 2v2
race => TPvZP
map => Monlyth Ridge
players => player 1(T)(w), player 2(P)(L) vs player3(Z)(W), player4(P)(W)
Length => 00-10-06

然后在~ (.*?) \( (\w) \) \( (\w) \) \s* ,? \s* (vs)? ~ msx上应用players应该会生成如下内容:

[2] => Array
    (
        [0] => T
        [1] => P
        [2] => Z
        [3] => P
    )

[3] => Array
    (
        [0] => w
        [1] => L
        [2] => W
        [3] => W
    )

这似乎足以制作您想要的输出字符串。