
Untitled
By: a guest on
Apr 15th, 2012 | syntax:
None | size: 0.99 KB | hits: 3 | expires: Never
private void generateRE(String word)
{
// ALL SUBSTITUTIONS OF 1 CHARACTER
for (int i=0; i<word.length(); i++)
{
Character c = word.charAt(i);
String s = word.replace(c.toString(), "[a-z]");
System.out.println("Sub: \\n" + s + "\\n");
}
// ALL INSERTIONS OF 1 CHARACTER
System.out.println("Ins: \\n[a-z]"+word+"\\n");
for (int i=0; i<word.length()-1; i++)
{
System.out.println("Ins: \\n" + word.substring(0, i+1) + "[a-z]" + word.substring(i+1, word.length()) + "\\n");
}
System.out.println("Ins: \\n"+word+"[a-z]\\n");
// ALL DELETIONS OF 1 CHARACTER
for (int i=0; i<word.length(); i++)
{
System.out.print("Del: \\n");
for (int j=0; j<word.length(); j++)
{
if (i!=j)
System.out.print(word.charAt(j));
}
System.out.println("\\n");
}
}