Programmazione:Java/Eclipse RCP/Documentazione Framework/Regular Expression Utility
Da WikiSitech.
Vai alla navigazioneVai alla ricerca<< Back to Documentazione Framework
public class FWKRegExpUtil {
public static boolean match(String filter, String text);
}
boolean match(String filter, String text)
Effettua il match tra il filtro e il testo passato convertendo prima il filtro in regular expression:
- Converte "*" in ".*".
- Converte i caratteri riservati come il "+" e "$" in "[+]" e "[$]".
- Gestisce gli spazi bianchi come "*" a meno che non contenuto in ' '.
- Aggiunge in cima al filtro "^" e alla fine "$" in modo da non effettuare il match sul contenuto ma sulla frase esatta.
Esempio:
String test = "ab c d efg";
FWKRegExpUtil.match("a", test); // FALSE
FWKRegExpUtil.match("a*", test); // TRUE
FWKRegExpUtil.match("'a b c'*", test); // FALSE
FWKRegExpUtil.match("'ab c'*", test); // TRUE
FWKRegExpUtil.match("a b c", test); // TRUE