In a general sense, you might run into serious problems with this, since what you are describing isn't "regular" (in the mathematical sense) and thus are going to be hard to use a regex to correctly capture. (Note here that ruby's regex patterns capture SLIGHTLY more than what is 'regular' too, so that helps some.) --- Tom Sawyer <transami / transami.net> wrote: > i find myself spending alot of time writing routines to parse > complex > strings. here's a mock example string of my current problem: > > a<b>[c]{d}"e"f {{g}} [[h]]*i**j*"k" > > and i want to parse this into an array like so: > > ['a','<b>','[c]','{d}','"e"','f','{{g}}','[[h]]','*i*','*j*','"k"'] > > for clearity here's another example: > > "a"{{b}}c{d}<e> -> ['"a"','{{b}}','c','{d}','<e>'] > > i have found such strings difficult to parse for a number of > reasons. > first, the text in double-quotations could contain bracket symbols > but > must be treated as plain text. second, [ and { brackets can be > nested as > in g and h of the first example. and finally, because whitespace > can > optionally occur between the parts. > > i wish ruby had some sort of parsing tool to make this childs play. > > can any of you geniuses out there offer an elegent solution? my > current > code dosen't work 100% and is like 90+ lines long. ugghh! > > ~transami > > > > > ===== -- Use your computer to help find a cure for cancer: http://members.ud.com/projects/cancer/ Yahoo IM: michael_s_campbell __________________________________________________ Do You Yahoo!? Sign up for SBC Yahoo! Dial - First Month Free http://sbc.yahoo.com