1
0
mirror of https://github.com/DanilaFe/abacus synced 2026-01-01 21:35:19 +00:00

Add sanitization to TreeBuilder.

This commit is contained in:
2017-07-27 15:26:02 -07:00
parent a7c2084254
commit b0ae3f90fc
2 changed files with 15 additions and 2 deletions

View File

@@ -235,4 +235,16 @@ public class Pattern<T> {
public PatternNode<T> getHead() {
return head;
}
public static String sanitize(String from){
Pattern<Integer> pattern = new Pattern<>("", 0);
from = from.replace(".", "\\.");
from = from.replace("|", "\\|");
from = from.replace("(", "\\(");
from = from.replace(")", "\\)");
for(Character key : pattern.operations.keySet()){
from = from.replace("" + key, "\\" + key);
}
return from;
}
}