Page 1 of 1

sscanf is my white whale

Posted: Fri May 05, 2006 4:53 am
by SpiderMonkey
Hi, I'd appreciate it if someone could look at this bit of code for me:

Code: Select all

$mi=1;
  foreach ($months as $month) {
      $searchstring="%[^1-9]%d[tsrn][htd] $month %d%[^[]]";
      if (sscanf($lsearch,$searchstring, $a, $b, $d, $e)>2) {
        if ($d<2000) $d+=2000;
        $datesearch="$b/$mi/$d";
        $locsearch="$a$e";
     }
     $mi++;
  }
Its intended to parse dates and remove them from the input string ($lsearch)
$months contains the short names of the months in order (jan,feb,mar etc)

I'm wanting it to pick up things like '5th may' but it isn't doing so.