java的正则表达式我想从网址的whatevername.css但我做错了什么,这些网址可能会发生变化,名称也因此它可能是的URL CSS文件名和扩展
www.asdasad.as /asdas/asdas/mystyles.css
asda.com/styles.css 等等等等
我试过这个(但它不工作“不能从方法,其结果返回值是无效” ):
String fileName = "www.whateverpage.es/style.css";
int idx = fileName.replaceAll("\\", "/").lastIndexOf("/");
return idx >= 0 ? fileName.substring(idx + 1) : fileName;
“它不工作”不是描述问题的好方法。你应该告诉我们你遇到了什么问题,如果你看到任何异常发布它的堆栈跟踪。请使用[[edit]]选项更新您的问题和其他信息。 – Pshemo