Java tutorial
package org.apache.commons.codec.language; import com.crumby.impl.crumby.UnsupportedUrlFragment; import com.crumby.impl.danbooru.DanbooruImageFragment; import com.crumby.impl.ehentai.HentaiSubGalleryFragment; import java.util.Locale; public class Caverphone2 extends AbstractCaverphone { private static final String TEN_1 = "1111111111"; public String encode(String source) { String txt = source; if (txt == null || txt.length() == 0) { return TEN_1; } return (txt.toLowerCase(Locale.ENGLISH).replaceAll("[^a-z]", UnsupportedUrlFragment.DISPLAY_NAME) .replaceAll("e$", UnsupportedUrlFragment.DISPLAY_NAME).replaceAll("^cough", "cou2f") .replaceAll("^rough", "rou2f").replaceAll("^tough", "tou2f").replaceAll("^enough", "enou2f") .replaceAll("^trough", "trou2f").replaceAll("^gn", "2n").replaceAll("mb$", "m2") .replaceAll("cq", "2q").replaceAll("ci", "si").replaceAll("ce", "se").replaceAll("cy", "sy") .replaceAll("tch", "2ch").replaceAll("c", "k").replaceAll("q", "k").replaceAll("x", "k") .replaceAll("v", "f").replaceAll("dg", "2g").replaceAll("tio", "sio").replaceAll("tia", "sia") .replaceAll("d", "t").replaceAll("ph", "fh").replaceAll("b", "p").replaceAll("sh", "s2") .replaceAll("z", DanbooruImageFragment.BREADCRUMB_NAME).replaceAll("^[aeiou]", "A") .replaceAll("[aeiou]", "3").replaceAll("j", "y").replaceAll("^y3", "Y3").replaceAll("^y", "A") .replaceAll("y", "3").replaceAll("3gh3", "3kh3").replaceAll("gh", "22") .replaceAll(HentaiSubGalleryFragment.BREADCRUMB_NAME, "k").replaceAll("s+", "S") .replaceAll("t+", "T").replaceAll("p+", "P").replaceAll("k+", "K").replaceAll("f+", "F") .replaceAll("m+", "M").replaceAll("n+", "N").replaceAll("w3", "W3").replaceAll("wh3", "Wh3") .replaceAll("w$", "3").replaceAll("w", "2").replaceAll("^h", "A").replaceAll("h", "2") .replaceAll("r3", "R3").replaceAll("r$", "3").replaceAll("r", "2").replaceAll("l3", "L3") .replaceAll("l$", "3").replaceAll("l", "2").replaceAll("2", UnsupportedUrlFragment.DISPLAY_NAME) .replaceAll("3$", "A").replaceAll("3", UnsupportedUrlFragment.DISPLAY_NAME) + TEN_1).substring(0, TEN_1.length()); } }