Differenze tra le versioni di "Programmazione:Java/Eclipse RCP/Documentazione Framework/Regular Expression Utility"
Da WikiSitech.
Vai alla navigazioneVai alla ricerca| (3 versioni intermedie di uno stesso utente non sono mostrate) | |||
| Riga 1: | Riga 1: | ||
| + | [[Programmazione:Java/Eclipse_RCP/Documentazione_Framework|<< Back to Documentazione Framework]]  | ||
| + | |||
<code java>  | <code java>  | ||
public class FWKRegExpUtil {  | public class FWKRegExpUtil {  | ||
| Riga 5: | Riga 7: | ||
</code>  | </code>  | ||
| − | + | '''boolean match(String filter, String text)'''  | |
| + | |||
Effettua il match tra il filtro e il testo passato convertendo prima il filtro in regular expression:  | Effettua il match tra il filtro e il testo passato convertendo prima il filtro in regular expression:  | ||
Versione attuale delle 09:22, 14 apr 2008
<< 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