Here you can find the source of toLowerSubset(String source, char substitute)
Parameter | Description |
---|---|
source | string to convert |
substitute | character to use |
public static String toLowerSubset(String source, char substitute)
//package com.java2s; public class Main { /**//from w w w. ja v a 2 s . c o m * Returns a string with non alphanumeric chars converted to the * substitute character. A digit first character is also converted. * By sqlbob@users * @param source string to convert * @param substitute character to use * @return converted string */ public static String toLowerSubset(String source, char substitute) { int len = source.length(); StringBuffer sb = new StringBuffer(len); char ch; for (int i = 0; i < len; i++) { ch = source.charAt(i); if (!Character.isLetterOrDigit(ch)) { sb.append(substitute); } else if ((i == 0) && Character.isDigit(ch)) { sb.append(substitute); } else { sb.append(Character.toLowerCase(ch)); } } return sb.toString(); } }