On 6/27/2012 6:26 PM, Paul Halliday wrote:
I have lines that look like (I added intentional line breaks): alert tcp $HOME_NET 10000 -> $EXTERNAL_NET any (msg:"ET EXPLOIT NDMP Notify Connect - Possible Backup Exec Remote Agent Recon"; flow:established,from_server; content:"|00 00 05 02|"; offset:16; depth:20; content: "|00 00 00 03|"; offset: 28; depth: 32; reference:url,www.ndmp.org/download/sdk_v4/draft-skardal-ndmp4-04.txt; reference:url,doc.emergingthreats.net/bin/view/Main/2002068; classtype:attempted-recon; sid:2002068; rev:8;) So within this there are reference urls that I would like to turn into links so that when they are rendered they can be clicked on. Using preg_match and this pattern I can get the refs: $pattern = '\reference:url,([^;]+;)\'; which gives me: $matches[0] = www.ndmp.org/download/sdk_v4/draft-skardal-ndmp4-04.txt $matches[1] = doc.emergingthreats.net/bin/view/Main/2002068 now what I would like to do is replace inline adding "<a href=http://" . $matches[n] . ">" . $matches[n] . "</a>" Can this be done or do I need to say loop through matches (there can be none or many) and do a str_replace. Thoughts? Other ideas? Thanks.
Look into preg_replace, with the "e" modifier. It allows you to run php code for every replace.
Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php