Jump to content

need to make this regex global


V for Vincent

Recommended Posts

Hi, I'm working on a kind of hack for cutenews (a content management system) that allows you to set timer to archive a given news item on a day of your choice (had a lot of outdated items last year). Now, I'm pretty new to the whole server side scripting thing, but I've got reliable posters, so I figured it would be easiest to just add a button that creates a tag that looks like this: [timer: dd-mm-yyyy] (enclosed in span tags that make it invisible).Then, whenever someone accesses my site's main page (server isn't mine, so I can't use anything like cron, which appears to be a common mechanism that would fulfil the same function slightly better), a tiny script checks an update log to see if timed posts have been deleted that day. If not, I need to check the posts for timers, which is where things start to become complicated for me.Here's what I've got:

$newsscan=file_get_contents("news.txt");//reads the file containing active news$scanresults=ereg("(<span class='timer'>)(\[timer: )([0-9]{2})(-)([0-9]{2})(-)([0-9]{4})(\])(</span>)",$newsscan,$results);//Search $newsscan for timers, place search results in an array $results.if ($scanresults) {print_r ($results);}

The final line is just to verify what the regex has found. The first value of the results array is indeed a timer, but I need to move all items containing a timer with an earlier timestamp than the day on which the script is run to the news archive.*edit* I did some extra research and I think I could do it using Perl style regular expressions. Still, is there a way to do this using POSIX?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...