Java examples for java.lang:String Strip
strip the characters we don't want.
//package com.java2s; public class Main { /**//from w w w .j a va 2 s . c om * Maybe move out at some point, most efficient way to strip the characters we don't want. * * @param in * @return */ public static String cleanPhoneNumber(String in) { //Hackeroo in = in.replace("+1", ""); StringBuilder sb = new StringBuilder(); char[] charArr = in.toLowerCase().toCharArray(); for (char c : charArr) { switch (c) { case '(': case ')': case '-': case ' ': break; default: sb.append(c); } } return sb.toString(); } }