Get the Google+ ID from a plus.google.com url https://plus.google.com/118064008740771173119 - Java Network

Java examples for Network:URL

Description

Get the Google+ ID from a plus.google.com url https://plus.google.com/118064008740771173119

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        String url = "java2s.com";
        System.out.println(googlePlusIdFromUrl(url));
    }/*from w w  w  . java  2 s. c o  m*/

    /**
     * Get the Google+ ID from a plus.google.com url
     * https://plus.google.com/118064008740771173119
     *
     * @param String url
     * @return String url
     */
    public static String googlePlusIdFromUrl(String url) {
        if (null == url) {
            return null;
        }
        String re = "(http)?s?(://)?(plus.)?google.com/?";
        url = url.replaceAll(re, "");
        return url;
    }
}

Related Tutorials