Regex: Simplify parameters of a java method (java.lang.String, xyz.Clazz -> String, Clazz) -


i need simple regex. goal simplify parameters of java method.

input: java.util.locale arg0, java.lang.string arg1, java.lang.object... arg2

output: locale arg0, string arg1, object... arg2

this how started, regex doesn't work yet.

pattern regex = pattern.compile("([a-z].*?)[a-z]", pattern.dotall); string str = "java.util.locale arg0, java.lang.string arg1, java.lang.object... arg2"; // replace groups (java.util., java.lang.) empty string // system.out.println(regex.matcher(str).replaceall("")); 

how can that?

the following prints locale arg0, string arg1, object... arg2:

pattern regex = pattern.compile("(\\w+\\.(?=\\w))+"); string str = "java.util.locale arg0, java.lang.string arg1, java.lang.object... arg2"; system.err.println(regex.matcher(str).replaceall("")); 

the regex match last dot such following character (not consumed regex, due lookahead), word character, e.g. letter. means works varargs, because have object... dot followed dot, rather word character.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -