how to form a regex that will parse the following? -


i need parse following line:

action(x,x,cash(50))action(y,y,material(30,car,2))action(i,i,cash(50)) 

the output should like:

action(x,x,cash(50)) action(y,y,material(30,car,2)) action(i,i,cash(50)) 

the regex used is:

string tokenregex = "(action+\\(([a-za-z]+|\\,|([a-za-z]+\\(\\d*|[a-za-z]+|\\,)\\))+\\))"; 

it fails parse "action(y,y,material(30,car,2))" works "action(x,x,cash(50))". doing wrong. correct regex?

i think it:

string tokenregex = "(action\\([a-za-z]+,[a-za-z]+,[a-za-z]+\\(\\d+(,([a-za-z]+|\\d+))*\\)\\))"; 

i removed parentheses weren't needed grouping in regular expression. if need them capturing parts of expression, you'll have add them back.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -