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.
我想D11-RONPLAYER_DEF_15_PO使用这个正则表达式进行匹配:
D11-RONPLAYER_DEF_15_PO
"D\[0-9]+-\[A-Z]*PLAYER_(DEF\[0-9]*)_(\[^_]+)_"
但它不匹配。我怎样才能让它工作?
这适用于您的示例输入:
regexp {D\d+-[A-Z]*PLAYER_(DEF_\d*)_([^_]+)} $str match sub1 sub2
打印匹配组产生:
% puts "$sub1\n$sub2" DEF_15 PO