Java tutorial
//package com.java2s; public class Main { /** * Strip the anchor link from a url * * @param url * @return */ public static String stripAnchor(String url) { int anchorIndex = url.indexOf('#'); if (anchorIndex > 0) { return url.substring(0, anchorIndex); } else { return url; } } }