正则表达式 - 一定长度或更小的仅匹配通配符 [英] Regex - only matching wildcard of a certain length or less
本文介绍了正则表达式 - 一定长度或更小的仅匹配通配符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
时有没有办法有一个与最大长度通配符正则表达式语句搜索?例如:
Is there a way to have a Regex statement search for a wildcard with a maximum length? For instance:
somestuff.*morestuff
如果我想上面的匹配
somestuffblahmorestuff
而不是
somestuffblahblahmorestuff
这可能吗?
推荐答案
要匹配已知长度使用 {2,5}
,其中2个是字符的最小数,5为最大。这两个值是可选的,但你确实需要一个或其他
To match a known length use .{2,5}
where the 2 is the minimum number of characters and 5 is the max. both values are optional but you do need one or the other
更多的可以在这个主题阅读的这里
More can be read on this topic here
这篇关于正则表达式 - 一定长度或更小的仅匹配通配符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文