Java Integer Create toIntExp(String charExp)

Here you can find the source of toIntExp(String charExp)

Description

Transform a char regexp into an int regexp w.r.t.

License

Open Source License

Parameter

Parameter Description
charExp a char regexp

Return

an int regexp

Declaration

public static String toIntExp(String charExp) 

Method Source Code

//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();
    }
}

Related

  1. toInternalValue(final double value)
  2. toInternalVariableName(String varName)
  3. toInternLink(String title, String url)
  4. toInterval(long i)
  5. toIntExact(long value)
  6. toIntFormat(String value)
  7. toIntHeader(String value)
  8. toIntLE(byte[] value)
  9. toIntList(String valus)