开发者

ruby-regex: how to match for "/table[number]"?

开发者 https://www.devze.com 2022-12-28 02:10 出处:网络
i want to match for all \"/table[number]\" so st开发者_开发知识库rings like \"/table[1]\" and \"/table\" are matched./\\/table(?:\\[\\d+\\])?/

i want to match for all "/table[number]"

so st开发者_开发知识库rings like "/table[1]" and "/table" are matched.


/\/table(?:\[\d+\])?/


Depending upon your needs, you may want to throw in word boundary markers as well. So

 /\b\/table(?:\[\d+\])?\b/

Without these the regex would match strings like
/tables
/tableTop
.....

0

精彩评论

暂无评论...
验证码 换一张
取 消