Hi I'm trying to extract the parameters from a class definition.
class locale.company.app.LoginData(username:String, password:String)
I have extracted the package name and class name, but the parameters are causing me some trouble.
I used Rubular to construct the following regex:
http://www.rubular.com/regexes/9597
According to Rubular this should work but it doesn't, as it will only match the first parameter. So i tried this regex instead:
classDescription = "class locale.company.app.LoginData(username:String, password:String)"
fieldMatches = classDescription.match(/(((\w+\s*):(\s*\w+))(\s*,\s*)?)+/)
I print out the matches using the following code:
fieldMatches.to_a.each {|m| puts m}
And I get this result:
username:String, password:String
password:String
password:String
password
String
,
This is only matching the second parameter for some reason. Does anyone know method to extract the parameters?