Rev 542 | Rev 744 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package org.tela_botanica.client.util;
public class Pattern {
public static final String url = "^(?:(?:ht|f)tp(?:s?)\\:\\/\\/|~/|/)?"+ // Protocol
"(?:\\w+:\\w+@)?"+ // Username:Password
"(?:(?:[-\\w]+\\.)+"+ // Subdomains
"(?:com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel|[a-z]{2}))"+ // TopLevel Domains
"(?::[\\d]{1,5})?"+ // Port
"(?:(?:(?:/(?:[-\\w~!$+|.,=]|%[a-f\\d]{2})+)+|/)+|\\?|#)?"+ // Directories
"(?:(?:\\?(?:[-\\w~!$+|.,*:]|%[a-f\\d{2}])+=(?:[-\\w~!$+|.,*:=]|%[a-f\\d]{2})*)(?:&(?:[-\\w~!$+|.,*:]|%[a-f\\d{2}])+=(?:[-\\w~!$+|.,*:=]|%[a-f\\d]{2})*)*)*"+ // Query
"(?:#(?:[-\\w~!$+|.,*:=]|%[a-f\\d]{2})*)?$"; // Anchor
public static final String email = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*"+ // Identité
"@"+ // At
"(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?";// Domaine
/**
* Méthode similaire à la méthode : java.util.Pattern.quote().
* java.util.Pattern n'est pas implémenté par GWT.
*
* @link http://java.developpez.com/faq/java/?page=langage_chaine
* @param s
* @return
*/
public static String quote(String s) {
int slashEIndex = s.indexOf("\\E");
if (slashEIndex == -1)
return "\\Q" + s + "\\E";
StringBuffer sb = new StringBuffer(s.length() * 2);
sb.append("\\Q");
slashEIndex = 0;
int current = 0;
while ((slashEIndex = s.indexOf("\\E", current)) != -1) {
sb.append(s.substring(current, slashEIndex));
current = slashEIndex + 2;
sb.append("\\E\\\\E\\Q");
}
sb.append(s.substring(current, s.length()));
sb.append("\\E");
return sb.toString();
}
}