Here you can find the source of toIntExp(String charExp)
Parameter | Description |
---|---|
charExp | a char regexp |
public static String toIntExp(String charExp)
//package com.java2s; public class Main { /**/*www .ja v a2s . c om*/ * Transform a char regexp into an int regexp w.r.t. the asci code of each character. * @param charExp a char regexp * @return an int regexp */ public static String toIntExp(String charExp) { StringBuilder b = new StringBuilder(32); for (int i = 0; i < charExp.length(); i++) { char c = charExp.charAt(i); if (c == '(' || c == ')' || c == '*' || c == '+' || c == '|') { b.append(c); } else { int n = (int) c; if (n >= 35) n--; if (n < 10) b.append(n); else b.append('<').append(n).append('>'); } } return b.toString(); } }