Java examples for Network:URL
Get Twitter username from twitter url
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { String url = "java2s.com"; System.out.println(twitterUsernameFromUrl(url)); }/*from ww w. ja v a2 s . c om*/ /** * Get Twitter username from twitter url * * @param String url * @return String url */ public static String twitterUsernameFromUrl(String url) { if (null == url) { return null; } String re = "(http)?s?(://)?(www.)?twitter.com/(#!/)?"; url = url.replaceAll(re, ""); return url; } }