G. T. Stresen-Reuter Regex to match parameter string of function
Mar 24, 2010; 04:12
G. T. Stresen-Reuter
Regex to match parameter string of function
Hi All.
I'm really stuck so hoping someone on the list can help. I'm looking for single regex that can find function calls with exactly 2 parameters. Basically, the regex pattern would look something like this:
\(\s*(.+?)\s*,\s*([^,\)]+?)\s*\)
However, the second parameter could contain anything, including commas and parentheses enclosed in quotes (or as part of a function that executes as the second parameter). Here are some example function calls that the pattern should find:
ereg('sdfs', ',)') ereg('sdfs', addslashes(',)'))
This is a function call that should NOT match:
ereg('sdfs', addslashes(',)'), $regs)
The one variable that will always be true is that if there is a third parameter it will always be preceded by a comma (and optional space) and match this regex: \$[a-z_][a-z0-9_]* (a valid variable name in PHP).
I suspect the answer may contain some combination of recursion and conditional patterns, but I just can't believe there isn't a simpler solution as in my experience, complex solutions simply aren't!
Thanks in advance to anyone who can lend a hand.
Sincerely,
Ted Stresen-Reuter http://tedmasterweb.com
-- You received this message because you are subscribed to the "BBEdit Talk" discussion group on Google Groups. To post to this group, send email to bbedit@googlegroups.com To unsubscribe from this group, send email to bbedit+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/bbedit?hl=en If you have a feature request or would like to report a problem, please email "support@barebones.com" rather than posting to the group.
To unsubscribe from this group, send email to bbedit+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
Mar 24
tedmasterweb Re: Regex to match parameter string of function
Mar 24, 2010; 09:02
tedmasterweb
Re: Regex to match parameter string of function
Search
Lasso Programming
This site manages and broadcasts several email lists pertaining to Lasso Programming and technologies related and used by Lasso developers. Sign up today!