Java tutorial
//package com.java2s; public class Main { public static String fixApplicationId(final String appId) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < appId.length(); i++) { final char ch = appId.charAt(i); if (ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' || ch >= '0' && ch <= '9' || ch == '-' || ch == '.') { builder.append(ch); } } return builder.toString(); } }