A
adrianae
Hi all
I have the following problem.
I have to test if a text matches with another text. For this i use the
matches-Method of the String class in the way:
String a = "Hello world";
String b = "anytext goes here_-)_some m[]ore text goes{}here.";
if (a.tolowercase().matches(b)) {
// some code goes here
}
The problem ist, that e.g. ),[],{} are reserved words in regex. To use
them in filter expressions i have to escape them with \). But how to
know what all i have to escape? There are so many other reserved
letters and signs in regex and the text i have to compare can contain
everything.
So my questions:
Is there in any class any helper function which knows all the reserved
sings and letters and that supplies a function which escapes me all
automatically?
Thank you
Adrian
I have the following problem.
I have to test if a text matches with another text. For this i use the
matches-Method of the String class in the way:
String a = "Hello world";
String b = "anytext goes here_-)_some m[]ore text goes{}here.";
if (a.tolowercase().matches(b)) {
// some code goes here
}
The problem ist, that e.g. ),[],{} are reserved words in regex. To use
them in filter expressions i have to escape them with \). But how to
know what all i have to escape? There are so many other reserved
letters and signs in regex and the text i have to compare can contain
everything.
So my questions:
Is there in any class any helper function which knows all the reserved
sings and letters and that supplies a function which escapes me all
automatically?
Thank you
Adrian