Java tutorial
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static String changeED2K(String url) { // TODO Auto-generated method stub Pattern pat = Pattern .compile("ed2k:\\/\\/\\|file\\|([^\\|]+?)\\|(\\d+)\\|([A-Z0-9]{32})\\|(h=[A-Z0-9]{32}\\|)?\\/?"); Matcher mat = pat.matcher(url); // System.out.println(url); if (mat.find()) { String name = "" + mat.group(1); if (name.contains(".")) { String temp = "1" + name.substring(name.lastIndexOf(".")); url = url.replace(name, temp); // System.out.println(url); } } if (url.startsWith("magnet:?xt=urn:btih:") && url.contains("&")) { url = url.substring(0, url.indexOf("&")).toLowerCase(); } return url; } }