只是为了好玩,另外几个版本;Java,仅限 US-ASCII,字符 0x14-0xc7;
public static String basicDecrypt(String input)
{
StringBuffer output = new StringBuffer();
Matcher matcher = Pattern.compile("(1..|[2-9].)").matcher(input);
while(matcher.find())
output.append((char)Integer.parseInt(matcher.group()));
return output.toString();
}
对于 0x1e-0xff,将正则表达式替换为"([12]..|[3-9].)"
...还有一个更简短的 Linq'y C# 版本。
private static string BasicDecrypt(string input)
{
return new string(Regex.Matches(input, "(1..|[2-9].)").Cast<Match>()
.Select(x => (char) Int32.Parse(x.Value)).ToArray());
}