Subversion Repositories eFlore/Applications.coel

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
542 jp_milcent 1
package org.tela_botanica.client.util;
2
 
3
public class Pattern {
728 jp_milcent 4
 
5
	public static final String url =  "^(?:(?:ht|f)tp(?:s?)\\:\\/\\/|~/|/)?"+ // Protocol
6
		"(?:\\w+:\\w+@)?"+ // Username:Password
7
		"(?:(?:[-\\w]+\\.)+"+ // Subdomains
8
		"(?:com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel|[a-z]{2}))"+ // TopLevel Domains
9
		"(?::[\\d]{1,5})?"+ // Port
10
		"(?:(?:(?:/(?:[-\\w~!$+|.,=]|%[a-f\\d]{2})+)+|/)+|\\?|#)?"+ // Directories
11
		"(?:(?:\\?(?:[-\\w~!$+|.,*:]|%[a-f\\d{2}])+=(?:[-\\w~!$+|.,*:=]|%[a-f\\d]{2})*)(?:&(?:[-\\w~!$+|.,*:]|%[a-f\\d{2}])+=(?:[-\\w~!$+|.,*:=]|%[a-f\\d]{2})*)*)*"+ // Query
12
		"(?:#(?:[-\\w~!$+|.,*:=]|%[a-f\\d]{2})*)?$"; // Anchor
13
 
14
	public static final String email = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*"+ // Identité
15
		"@"+ // At
16
		"(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?";// Domaine
17
 
1113 jpm 18
	public static final String heureMinute = "^(?:[0-1][0-9]|2[0-4])"+ // Heure au format 24h
1112 jpm 19
		":"+ // Séparateur d'heure et minute
20
		"(?:[0-5][0-9]|60)$"; // Minutes;
885 aurelien 21
 
542 jp_milcent 22
	/**
23
	 * Méthode similaire à la méthode : java.util.Pattern.quote().
24
	 * java.util.Pattern n'est pas implémenté par GWT.
744 jpm 25
	 * Nous protégeons les caractères spéciaux.
542 jp_milcent 26
	 *
27
	 * @link http://java.developpez.com/faq/java/?page=langage_chaine
744 jpm 28
	 * @param chaine
542 jp_milcent 29
	 * @return
30
	 */
744 jpm 31
	public static String quote(String chaine) {
32
		chaine.replace("\\", "\\\\");
33
 
948 jpm 34
		String[] caracteresSpeciaux = {".", "$", "[", "]", "(", ")", "{", "}", "^", "?", "*", "+", "-", "|"};
744 jpm 35
		for (int i = 0; i < caracteresSpeciaux.length; i++) {
36
			chaine = chaine.replace(caracteresSpeciaux[i], "\\"+caracteresSpeciaux[i]);
542 jp_milcent 37
		}
744 jpm 38
		return chaine;
542 jp_milcent 39
	}
40
}