如何在 Mushclient 中使用正则表达式匹配任何房间描述

我想生成一个正则表达式,可以将房间描述匹配如下:

My Room Description(enter, n, s, e 和 w)
My Room Description(enter, e, s, w 和 n)
My Room Description(s, w, e, n 和 enter)
My Room Description(n, e, w, s 和 enter)

出口方向可能在不同的位置,但一定是同样数量的 (4)。

这应该_不是_匹配的:

My Room Description(n, up, e, w, s and enter)

因为它有_5_个出口(除“enter”之外)。

点赞
用户256196
用户256196

尝试这个:

^ My Room Description\((\w+(, | and )?){5} \)$

查看实时演示


为了允许可选的前导文本,例如您的评论中的“HP:245 EP:245 >>”:

^[\w: >]* My Room Description\((\w+(, | and )?){5} \)$

或者更严格:

^([\w: ]* >>)? My Room Description\((\w+(, | and )?){5} \)$

这将仅限制前导字符为您提供的示例字符。为了允许任何东西:

^.* My Room Description\((\w+(, | and )?){5} \)$
2019-02-22 03:50:18