Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我希望此文本匹配:
test123 id=125456
这是我的正则表达式不起作用:
([iI]{1,1}[dD]{1,1}=((d+).))|([A-Za-z0-9]*)
谁能告诉我我错过了什么?第二个样本不起作用。
您需要使用\d+来匹配多个数字。 d+寻找重复字符d:
\d+
d+
d
...((\d+).))|( ^^ add \ in front of d
工作示例:http ://www.rubular.com/r/R8cxjZoG58
这可以解决问题: ([iI][dD]=\d+)|([A-Za-z0-9]*)
([iI][dD]=\d+)|([A-Za-z0-9]*)
几点建议:
[iI]{1,1}
[iI]{1}
{1}