mirror of
https://github.com/DanilaFe/abacus
synced 2026-01-01 13:25:19 +00:00
Add sanitization to TreeBuilder.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user