The following is a sample string I’m using:
http://www.asfradio.com/device.asp?u=username&p=password&s=east
Current checks I use in my code:
if (data.endsWith(".asf") || (0 < data.indexOf(".asf")))
So in this case my check fails because yes there is a .asf string but it’s followed by radio and that makes my logic bad since this link is not asf type…
What I want is a regular expression which returns true if “.asf” is found and the next character after “f” is not a letter.
Hopefully it make sence…
In Java’s regex engine, you have the word boundary anchor
\bSearch for
\\.asf\\b. In order to use that with String.matches(), you will have to wrap it with.*:Better yet, store the compiled pattern in a constant:
And use it like this: