I need to know if we check the end of the line with something like .xyz plus any characters after it.
Like this:
myString.endsWidth(".css*")
However, this does not pass my if-statement. One specific example of such a line: style.css?v=a1b23
style.css?v=a1b23
Any ideas?
Full example String:
http://xyz.com//static/css/style.css?v=e9b34
buzz, I guess something like this is even better:
return myString.indexOf(".css")>-1;
If you really want to use regex, you can use this
return myString.matches(".*?\\.css.*");
endsWith takes a string as parameter
endsWith
matches takes a regex
matches
Use ".*\.css.+" As your regular expression.
".*\.css.+"
use \.(.{3})(.*) , then the first group ($ 1) contains three characters after . and the second group of $ 2 contains the rest of the line after these three characters. Add a $ sign at the end of the expression so that it looks only for lines ending with this combination
\.(.{3})(.*)
.
Try some regular expressions:
Pattern p = Pattern.compile(".*\.css.*"); Matcher m = p.matcher("mystring"); if (m.matches()) { // do your stuff }