Java Regex Matcher Question
Posted
by Yang
on Stack Overflow
See other posts from Stack Overflow
or by Yang
Published on 2010-04-04T04:12:46Z
Indexed on
2010/04/04
4:23 UTC
Read the original article
Hit count: 468
How do I match an URL string like this:
img src = "http://stackoverflow.com/a/b/c/d/someimage.jpg"
where only the domain name and the file extension (jpg) is fixed while others are variables?
The following code does not seem working:
Pattern p = Pattern.compile("<img src=\"http://stachoverflow.com/.*jpg");
// Create a matcher with an input string
Matcher m = p.matcher(url);
while (m.find()) {
String s = m.toString();
}
© Stack Overflow or respective owner