Match the last backslash/trailing content in the URL URLs with regular expressions

Source: Internet
Author: User

Test content:

http://b174.photo.store.qq.com/psb?/V10CD1yE07IujV/embkzb1rzhy56uejjcdlosr3hhqy53jbobtl7zh9lug!/c/ Dk4aaaaaaaaa&bo=faf0aaaaaaafaco!&rf=mood_app
https://www.zhihu.com/question/37415530/answer/118246241?group_id=751055135773331456
http://zhidao.baidu.com/question/185463932.html
http://billmill.org/bloomfilter-tutorial/
http://music.163.com/

Test results:

Total 3 matches found:
Dk4aaaaaaaaa&bo=faf0aaaaaaafaco!&rf=mood_app
118246241?group_id=751055135773331456
185463932.html

Regular Expressions:

[^/]+(?!. */)

Analytical:

[^/]+ is a string that matches any length, and the string does not contain characters/, it can match the/split string to the full.

. */denotes any string that ends with a/, can be matched to a string followed by A/, preceded by a?!, and then wrapped in parentheses to exclude. (?!. */).
The entire expression is meant to match any length of the string that does not contain/, and the string that ends with a/end is excluded.

Match the last backslash/trailing content in the URL URLs with regular expressions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.