开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜