[英]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?有没有办法让 Regex 语句搜索具有最大长度的通配符? For instance:例如:
somestuff.*morestuff
If I wanted the above to match如果我希望以上匹配
somestuffblahmorestuff
but not但不是
somestuffblahblahmorestuff
Is this possible?这可能吗?
In regex:在正则表达式中:
{n}
Matches the previous element exactlyn
times.精确匹配前一个元素n
次。
{n,}
Matches the previous element at leastn
times.至少匹配前一个元素n
次。
{n,m}
Matches the previous element at leastn
times, but no more thanm
times.匹配前一个元素至少n
次,但不超过m
次。
For example:例如:
,\d{3}
matches ,876
, ,543
, and ,210
in 9,876,543,210
,\d{3}
匹配9,876,543,210
中的,876
, ,543
和,210
\d{2,}
matches 166
, 29
, 1930
\d{2,}
匹配166
, 29
, 1930
\d{3,5}
matches 19302
in 193024
\d{3,5}
匹配19302
中的193024
somestuff.{4,7}morestuff
{min, max} is the syntax to specify the number of repetition. {min, max} 是指定重复次数的语法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.