Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { private static String getHash(String s) { if (s.contains("/comment/")) { s = s.substring(0, s.indexOf("/comment")); } String next = s.substring(s.lastIndexOf("/"), s.length()); if (next.contains(".")) { next = next.substring(0, next.indexOf(".")); } if (next.startsWith("/")) { next = next.substring(1, next.length()); } if (next.length() < 5) { return getHash(s.replace(next, "")); } else { return next; } } }