dsaba Posted March 1, 2008 Share Posted March 1, 2008 I'm trying to match php like function declarations that have 1 argument in them. The problem is matching proper digits with an if/else expression. The root of the problem is here: (??=\.)[\d]+|\d+\.?\d*) Full pattern: (?<![\w_])[a-z][\w_]*\s*\(\s*(((?<![\$\w_])[\$a-z][\w_]*(?![\$\w_]|\s*\()\s*=\s*)?((?<![\$\w_])[\$a-z][\w_]*(?![\$\w_]|\s*\()|"[^"]*"|(??=\.)[\d]+|\d+\.?\d*)))\s*\) Haystack: thisFunc("hello"); //yes thisFunc($var = "hello"); //yes name(var = var); //yes name(var = 2.3); //yes name(var = 2.3.); //no name(.5) //yes [here is the problem it doesn't match here] name(var = .58) //yes [here is problem, it doesn't match here] name(var = .5. //no So how can I match these numbers? either .23 or 0.23, it doesn't match .23 types Thanks for looking. Quote Link to comment Share on other sites More sharing options...
dsaba Posted March 1, 2008 Author Share Posted March 1, 2008 changed it to this and works as expected: (\d+|\.\d+|\d+\.\d*) if you've got a better idea, let me know Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.