I want to write a RegEx to pull out all the variable values and their names from the variable declaration statement. Say i have
int i,k = 10,l=0
i want to write a regex something like int\s^,?|(^,?)* but this will also accept k = 10 i.e. (without int preceding it) Basically idea is If string starts with int then get the variable list seperated by ,
i know to extract csv values, but here my string has some initial value as well. How can i resolve it?
Here is some useful information which you can use
http://compsci.ca/v3/viewtopic.php?t=6712
Start thinking about the structure of a definition, say,
then try to convert each group:
Left as homework to remove spaces and fix up the final regex.
You could build up your regular expression from the [C# Grammar](http://msdn.microsoft.com/en-us/library/aa664812(VS.71).aspx). But building a parser would certainly be better.
Try this:
It'll match your example code
And making a few assumptions about the language you may or may not be using, it'll also match: