regex - Java Camel case apostrophe issue -


can please regarding camel casing strings contain apostrophes, whereby don't want next letter after apostrophe put upper case.

my code reads txt file , processes accordingly.

for example "matthew smith" converted "matthew smith" "matthew s'mith" converted "matther s'mith" when should "s'mith"

    public static string tocamelcase(string tmp){     pattern p = pattern.compile(camel_case_reg_exp);     matcher m = p.matcher(tmp);     stringbuffer result = new stringbuffer();     string word;     while (m.find())      {         word = m.group();                      result.append(word.substring(0,1).touppercase()+word.substring(1).tolowercase());      }     return result.tostring(); } public static final string camel_case_reg_exp = "([0-9]+)?([a-za-z]+)(\\')?(\\-)?(\\s)?"; 

thanks in advance.

try regex

public static final string camel_case_reg_exp = "\\s*\\s+\\s*"; 

it produces

matthew s'mith 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -