| CODE |
| <TEXTFORMAT LEADING="2"><P ALIGN="left"><FONT FACE="arial" SIZE="12" COLOR="#000000">texte.... pas de retour dans ce block inline</FONT></P></TEXTFORMAT> |
| CODE |
| <TEXTFORMAT LEADING="2"><P ALIGN="left"><FONT FACE="arial" SIZE="12" COLOR="#000000">texte.... pas de retour dans ce block inline</FONT></P></TEXTFORMAT> |
| CODE |
| str = Pattern.compile("\\[i\\]([^\\[]*[^/]*[^i]*[^\\]]*)\\[/i\\]").matcher(str).replaceAll("<i>$1</i>"); |
| QUOTE |
| ([^\\[]*[^/]*[^i]*[^\\]]*) |
| QUOTE |
| tout sauf le mot x |
| CODE |
| static String[] acrstr = {"as", "asp", "atom", "html", "js", "jsfl", "jsp", "jspx", "jar", "jni", "php", "sql", "uml", "xml"}; static String[] acrrep = {"Action Script", "Active Server Page", "Atom Syndication", "Hyper Text Markup Language", "JavaScript", "JavaScript for Flash IDE", "Java Server Page", "Java Server Page Xml structured", "Java ARchive", "Java Native Integration", "Hypertext PreProcessor", "Structured Query Language", "Unified Modelisation Language", "eXtensible Markup Language"}; |
| CODE |
| for(int i = 0; i < acrstr.length; i++){ while(str.indexOf(acrstr[i]) != -1){ str = str.substring(0, str.indexOf(acrstr[i])) + "<acronym title='" + acrrep[i] + "'>" + acrstr[i] + "</acronym>" + str.substring(str.indexOf(acrstr[i]) + acrstr[i].length(), str.length() - 1); } } |
| CODE |
| for(int i = 0; i < acrstr.length; i++){ str = Pattern.compile("(\\p{Blank}|\\p{Punct})" + acrstr[i]).matcher(str).replaceAll("$1<acronym title='" + acrrep[i] + "'>" + acrstr[i] + "</acronym>"); } |
| CODE |
| // tabulation, espaces blancs en quantité while(str.indexOf(" ") != -1){ // ne fait pas plus de deux boucles str = Pattern.compile("([ ]{2})").matcher(str).replaceAll(" "); } |
| QUOTE |
| Voilà, quand je redémarre tomcat, toutes les pages jsp et autres servlets / beans sont \"lents\" à s'exécuter... |
| QUOTE |
| J'essaie d'augmenter l'utilisation de la ram par tomcat |
| QUOTE |
| Voici le bean qui formate justement ces textes : ici |
| CODE |
| import java.util.regex.*; public class Formatter{ private final static Pattern _pattern = Pattern.compile("lePattern"); public final String format(String str){ return _pattern.matcher(str).replaceAll("remplacement'") } } |
| CODE |
| // smilies static Pattern[] _smiley = {Pattern.compile("(^| |\\n|\\r)"+":\\)"), Pattern.compile("(^| |\\n|\\r)" + ":\\-\\-\\>:"), Pattern.compile("(^| |\\n|\\r)" + "(:D|:d|:mrgreen:)"), Pattern.compile("(^| |\\n|\\r)" + ":0"), Pattern.compile("(^| |\\n|\\r)" + "8\\)"), Pattern.compile("(^| |\\n|\\r)" + ":/"), Pattern.compile("(^| |\\n|\\r)" + ";\\)"), Pattern.compile("(^| |\\n|\\r)" + "\\^\\^"), Pattern.compile("(^| |\\n|\\r)" + ":(p|P)"), Pattern.compile("(^| |\\n|\\r)" + "8\\|"), Pattern.compile("(^| |\\n|\\r)" + "8:0"), Pattern.compile("(^| |\\n|\\r)" + ":\\=\\)"), Pattern.compile("(^| |\\n|\\r)" + "\\=\\)"), Pattern.compile("(^| |\\n|\\r)" + ":\\$"), Pattern.compile("(^| |\\n|\\r)" + ":\\("), Pattern.compile("(^| |\\n|\\r)" + ":\\."), Pattern.compile("(^| |\\n|\\r)" + ":\\?:"), Pattern.compile("(^| |\\n|\\r)" + ":\\!:"), Pattern.compile("(^| |\\n|\\r)" + ":no:"), Pattern.compile("(^| |\\n|\\r)" + ":mad:"), Pattern.compile("(^| |\\n|\\r)" + ":cute:"), Pattern.compile("(^| |\\n|\\r)" + ":evil:"), Pattern.compile("(^| |\\n|\\r)" + ":\\|"), Pattern.compile("(^| |\\n|\\r)" + ":idea:"), Pattern.compile("(^| |\\n|\\r)" + ":knife:"), Pattern.compile("(^| |\\n|\\r)" + ":female:"), Pattern.compile("(^| |\\n|\\r)" + ":male:"), Pattern.compile("(^| |\\n|\\r)" + ":love:"), Pattern.compile("(^| |\\n|\\r)" + ":lol:"), Pattern.compile("(^| |\\n|\\r)" + "8\\^"), Pattern.compile("(^| |\\n|\\r)" + ":scared:"), Pattern.compile("(^| |\\n|\\r)" + ":zzz:"), Pattern.compile("(^| |\\n|\\r)" + ":\\^"), Pattern.compile("(^| |\\n|\\r)" + ":\\-:"), Pattern.compile("(^| |\\n|\\r)" + ":abstract:"), Pattern.compile("(^| |\\n|\\r)" + ":climat:"), Pattern.compile("(^| |\\n|\\r)" + ":faq:"), Pattern.compile("(^| |\\n|\\r)" + ":firefox:"), Pattern.compile("(^| |\\n|\\r)" + ":flail:"), Pattern.compile("(^| |\\n|\\r)" + ":gallery:"), Pattern.compile("(^| |\\n|\\r)" + ":glomp:"), Pattern.compile("(^| |\\n|\\r)" + ":hands:"), Pattern.compile("(^| |\\n|\\r)" + ":kissbow:"), Pattern.compile("(^| |\\n|\\r)" + ":nolistening:"), Pattern.compile("(^| |\\n|\\r)" + ":nonono:"), Pattern.compile("(^| |\\n|\\r)" + ":realy:"), Pattern.compile("(^| |\\n|\\r)" + ":square:"), Pattern.compile("(^| |\\n|\\r)" + ":sword:"), Pattern.compile("(^| |\\n|\\r)" + ":threaten:"), Pattern.compile("(^| |\\n|\\r)" + ":teddy:"), Pattern.compile("(^| |\\n|\\r)" + ":wave:"), Pattern.compile("(^| |\\n|\\r)" + ":work:"), Pattern.compile("(^| |\\n|\\r)" + ":work2:"), Pattern.compile("(^| |\\n|\\r)" + ":what:"), Pattern.compile("(^| |\\n|\\r)" + ":yummy:")}; // attention, regex static String[] replace = {"smile", "arrow", "biggrin", "surprised", "cool", "confused", "wink", "spin", "razz", "neutral", "eek", "tooth", "yes", "redface", "sad", "potatoheader", "question", "exclam", "no", "mad", "cute", "evil", "eyebrow", "idea", "knife", "female", "male", "love", "lol", "rolleyes", "scared", "sleep", "whistle", "_", "abstract", "climat", "faq", "firefox", "flail", "gallery", "glomp", "handshake", "kissbow", "nolistening", "nonono", "realy", "square", "sword", "threaten", "teddy", "wave", "work", "work2", "what", "yummy"}; // attention aux guillemets static String[] title = {":)", ":-->:", ":D", ":0", "8)", ":/", ";)", "^^", ":P", "8|", "8:0", ":=)", "=)", ":\\$", ":(", ":.", ":?:", ":!:", ":no:", ":mad:", ":cute:", ":evil:", ":|", ":idea:", ":knife:", ":female:", ":male:", ":love:", ":lol:", "8^", ":scared:", ":zzz:", ":^", ":-:", ":abstract:", ":climat:", ":faq:", ":firefox:", ":flail:", ":gallery:", ":glomp:", ":hands:", ":kissbow:", ":nolistening:", ":nonono:", ":realy:", ":square:", ":sword:", ":threaten:", ":teddy:", ":wave:", ":work:", ":work2:", ":what:", ":yummy:"}; // attention aux guillemets ... // le début de la fonction for(int i = 0; i < _smiley.length; i++){ str = _smiley[i].matcher(str).replaceAll("$1<img src='/smiley:"+replace[i]+"' class='smiley' title='"+title[i]+"' alt='"+title[i]+"' />"); } |
| CODE |
| static { code... } |