Artiom Posted October 16, 2006 Share Posted October 16, 2006 [code]<?php$d="INSERT INTO PlaceholderInfo(PlaceholderInfoID, MsgClassName, Placeholder, Description, Sample, ListPrefix, UserArc, DateArc )VALUES (5,'Trouble Ticket Notification','Ticket_Level_Description','General ticketinfo : Description of ticket Support Level','Front Level of Support',NULL,0,0);";$a=addslashes("VALUES\s\([\d]+,'([\w\s\d]+)','[\w\s\d]+','([\w\s\d\:]+)");ereg ('VALUES\s\([\d]+\',\'([\w\s\d]+)\',\'[\w\s\d]+\',\'([\w\s\d\:]+)', $d, $regs);echo "$regs[2] $regs[1]";//echo $a;?>[/code]I have a code, the goal is to get the second and fourth elements from the DB querry. As the result of operation $regs should contain the necessary elements, but it is empty :(I've checked the regular expression in Espresso - it works just fine. Hepl please!Pure regexsp as I had checked in EspressoVALUES\s\([\d]+\',\'([\w\s\d]+)\',\'[\w\s\d]+\',\'([\w\s\d\:]+) Quote Link to comment Share on other sites More sharing options...
effigy Posted October 16, 2006 Share Posted October 16, 2006 ereg does not support \s, \d or \w: use preg.[code]<pre><?php$d="INSERT INTO PlaceholderInfo(PlaceholderInfoID, MsgClassName, Placeholder, Description, Sample, ListPrefix, UserArc, DateArc )VALUES (5,'Trouble Ticket Notification','Ticket_Level_Description','General ticketinfo : Description of ticket Support Level','Front Level of Support',NULL,0,0);";preg_match('%VALUES\s\(\d+,\'([\w\s\d]+)\',\'[\w\s\d]+\',\'([\w\s\d\:]+)%', $d, $regs);print_r($regs);?></pre>[/code] Quote Link to comment Share on other sites More sharing options...
Artiom Posted October 17, 2006 Author Share Posted October 17, 2006 Wow, million of thanx! This works just fine! 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.