Writing D:/inetpub/webs/vincenzodevivocom/wiki/data/cache/0/0466803c07c02daf47e3e2e15e913c72.i failed
Unable to save cache file. Hint: disk full; file permissions; safe_mode setting.
Writing D:/inetpub/webs/vincenzodevivocom/wiki/data/cache/0/0466803c07c02daf47e3e2e15e913c72.i failed
Unable to save cache file. Hint: disk full; file permissions; safe_mode setting.
Writing D:/inetpub/webs/vincenzodevivocom/wiki/data/cache/0/0466803c07c02daf47e3e2e15e913c72.xhtml failed

String Utils

Pattern UpperCase/LowerCase

     public static String patternLowerCase(String pattern, String string) {
        if (string == null){
            return null;
        }
        Matcher m = Pattern.compile(pattern).matcher(string);
 
        StringBuffer sb = new StringBuffer();
        while (m.find()) {
            m.appendReplacement(sb, m.group().toLowerCase());
        }
        m.appendTail(sb);
 
     return sb.toString();
    }
    public static String patternUpperCase(String pattern, String string) {
        if (string == null){
            return null;
        }
        Matcher m = Pattern.compile(pattern).matcher(string);
 
        StringBuffer sb = new StringBuffer();
        while (m.find()) {
            m.appendReplacement(sb, m.group().toUpperCase());
        }
        m.appendTail(sb);
 
     return sb.toString();
    }

Example of use:

//Here's an example of how you use regex to find and capitalize words of length at least 3 in a sentence 
String text = "example of how you use";
String pattern = "\b\w{3,}\b";
String res = patternUpperCase(pattern, text);
System.out.println(res);
// prints "EXAMPLE of HOW YOU USE"
 
code/java/string_utils.txt · Last modified: 2012/05/02 14:57 by Vincenzo De Vivo
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki