如何创建 REGEX 来检测“字符串 url”是否包含文件扩展名(.pdf、.jpeg、.asp、.cfm...)?
有效(无扩展名):
无效(带扩展名):
- http://www.thesis.com/paper.pdf
- http://pics.co.uk/mypic.png
- http://jpeg.com/images/cool/the_image.JPEG
谢谢, 塞尔索
最佳答案
在 Java 中,最好使用 String.endsWith()这更快,更容易阅读。 示例:
"file.jpg".endsWith(".jpg") == true
关于Java 正则表达式 : How detect a URL with file extension,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5187235/