Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static final String INTERNATION_PREFIX = "+86";
    public static final String COMMON_PREFIX = "17951";

    public static String getPureTel(String tel) {
        if (null == tel) {
            return tel;
        }
        String pureTel = tel.trim();
        if (pureTel.startsWith(INTERNATION_PREFIX)) {
            pureTel = pureTel.substring(INTERNATION_PREFIX.length());
        }
        if (pureTel.startsWith(COMMON_PREFIX)) {
            pureTel = pureTel.substring(COMMON_PREFIX.length());
        }
        return pureTel.replaceAll("[\\D]", "");
    }
}