-2

I need get specific url with start : "nbp.pl/kursy/xml/c" and ending "z070413.xml" Between c and z is 3 numbers from 0 to 9. How can i get all this urls ?

pawel033
  • 11
  • 1
  • 4

1 Answers1

2

You could use the following regex pattern:

^nbp\.pl/kursy/xml/c[0-9]{3}z070413\.xml$

Sample Java code:

String url = "nbp.pl/kursy/xml/c123z070413.xml";
if (url.matches("nbp\\.pl/kursy/xml/c[0-9]{3}z070413\\.xml")) {
    System.out.println("URL is a match");
}

The three digits in between the c and z is represented by [0-9]{3}, and also literal dot \. needs to be escaped in the regex using a backslash.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360