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\:]+) Link to comment https://forums.phpfreaks.com/topic/24052-help-with-regexp-in-php/ 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] Link to comment https://forums.phpfreaks.com/topic/24052-help-with-regexp-in-php/#findComment-109551 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! Link to comment https://forums.phpfreaks.com/topic/24052-help-with-regexp-in-php/#findComment-109869 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.