我有一些数据,由多个方括号内的值组成,看起来像这样: name [Tom] state [NewYork] phone [5555] 我想提取状态。这是我使用的正则表达式,但它返回空白。 Regex: state \[(.+?)\] Template: $1$ Match No.: 1 我看不出这里有什么错误?
\s+
代替字面上的空格。 - Wiktor Stribiżewstate \[(\w+)\]
,因为它更符合你的情况。 - streetturtle