以数字结尾的URI的正则表达式

时间:2016-08-21 02:43:44

标签: regex

请为我的网址建议正则表达式。我试图解析一个应该在最后一个尾部斜杠之后只有数字的URL:

http://localhost/myproj/myservice/api/v4/lists/45678333

当我尝试这个正则表达式时:

(http|https)://([A-z0-9|\.|\-]*)/myproj/myservice/api/v([.\d{1}])/lists/(.\d+$)

它也接受a45678333作为最后一个号码。我只是想成为任何长度的数字。

如何在最后一次斜杠后形成与数字(且只是数字)匹配的正则表达式?

2 个答案:

答案 0 :(得分:1)

$('.translateSearch').on('change', function(e) { if ($(this).prop('checked')) { $('.SearchInput').attr('placeholder', 'Have your search terms translated to Chinese.'); } else { $('.SearchInput').attr('placeholder', 'Search using exact terms.'); } }); 匹配/(.\d+$),然后是任意单个字符,后跟任意数字的数字。

要仅匹配最后的数字,您需要:

/

如果要捕获组中的数字:

/\d+$

答案 1 :(得分:0)

试试this regular expression,它会帮助你:

(http|https):\/\/([A-z0-9|.|-]*)\/myproj\/myservice\/api\/v(‌​[.\d{1}])\/lists\/(​\d+$)
相关问题