fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.util.regex.Matcher;
  5. import java.util.regex.Pattern;
  6.  
  7. class Ideone
  8. {
  9. public static void main (String[] args) throws java.lang.Exception
  10. {
  11. String regex = "^https?://\\S+\\.mp3$";
  12. String[] strings = {
  13. "https://w...content-available-to-author-only...x.com/examples/mp3/SoundHelix-Song-1.mp3",
  14. "https://w...content-available-to-author-only...x.com/examples/mp3/SoundHelix-Song-1.mp4"
  15. };
  16. Pattern pattern = Pattern.compile(regex);
  17. for (String s : strings) {
  18. Matcher matcher = pattern.matcher(s);
  19. if (matcher.find()) {
  20. System.out.println(matcher.group(0));
  21. }
  22. }
  23. }
  24. }
Success #stdin #stdout 0.05s 2184192KB
stdin
Standard input is empty
stdout
https://w...content-available-to-author-only...x.com/examples/mp3/SoundHelix-Song-1.mp3