星际争霸重播正则表达式,括号问题

发布于 2024-11-09 02:36:06 字数 327 浏览 5 评论 0原文

[2v2] 种族=[TPvZP] 地图=[月岭] 玩家=[玩家 1(T)(w)、玩家 2(P)(L) vs 玩家 3(Z)(W)、玩家 4(P)(W) ] Length=[00-10-06]

在 TheLittleOne(职业玩家)的星际争霸网站工作时,我正在努力寻找以下情况的正则表达式。 [ 括号导致正则表达式过长。

我想要以下的刺 例如) 游戏类型:2v2 比赛:TPvZP 地图: 蒙利斯岭 玩家1:姓名 玩家2:姓名 玩家3:姓名 玩家4:姓名 玩家 1-4:比赛(P、T、Z、R) 玩家 1-4:获胜 (W,L) 游戏时长:10分6秒。

我已经搜索了好几天了,似乎找不到解决方案。

[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]

Working in a Starcraft site for TheLittleOne (a pro player), I'm struggling to find the regex for the following situation. The [ brackets are causing the regex expression to be to long.

I want the following stings
EG)
The gametype: 2v2
The race: TPvZP
Map: Monlyth Ridge
Player1:Name
Player2:Name
Player3:Name
Player4:Name
Player1-4:Race (P,T,Z,R)
Player 1-4: Win (W,L)
Game Length: 10 Minutes 6 seconds.

I've searched S.O. for several days and I can't seem to find a solution.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自演自醉 2024-11-16 02:36:06

给定字符串 [2v2]race=[TPvZP]map=[Monlyth Ridge]players=[玩家 1(T)(w), 玩家 2(P)(L) vs 玩家 3(Z)(W), 玩家 4 (P)(W)]长度=[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* (对比)? players 上的 ~ msx 应该产生类似这样的内容:

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

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

这似乎足以生成您想要的输出字符串。

Given the string [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 will produce the following:

"" => 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

then applying ~ (.*?) \( (\w) \) \( (\w) \) \s* ,? \s* (vs)? ~ msx on players should produce something like this:

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

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

which seems to be enough to make your desired output string.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文