From: pondus Date: 2006-10-30T14:30:12+09:00 Subject: Regex to transform java code to ecma script Hi, I was hoping someone could provide me with a better way to accomplish (preferrably in one line) the following simple task: # typical method declaration in a java interface code = "public void myFunction(String foo);" # needs to be transformed into the following e.g. Actionscript 2.0 (ECMA) # public function myFunction(foo:String):Void; java = code.gsub(/(public) (.*?) (.*).*(;)/) { $1 + ' function ' + $3 + ':' + $2.capitalize + ";" } puts code.gsub(/\((String) (foo)\)/,'(\2:\1)') It works, but it's not very slick.. Thanks! Peder :)