I have a fairly complicated regular expression that was written for perl.

I've spent the last 4 days trying to convert it to PHP.

I guess I'm just that bright.

I can't even get the sub parts (between the || to work, much less the
conditionals

Would someone mind showing me how I can make this work in PHP?

Thanks

walter

# Does input match this RegEx?

     (($day,$mon,$yr,$hr,$min,$sec,$tz) =
 /^
  (\w{1,3})             # month
     \s+
  (\d\d?)               # day
     \s+
  (\d\d?):(\d\d)        # hour:min
  (?::(\d\d))?          # optional seconds
     \s+
  (?:([A-Za-z]+)\s+)?   # optional timezone
  (\d+)                 # year
     \s*$               # allow trailing whitespace
 /x)


# If not that one, then this RegEx?
    ||

    # Then the Unix 'ls -l' date format
    (($mon, $day, $yr, $hr, $min, $sec) =
 /^
  (\w{3})               # month
     \s+
  (\d\d?)               # day
     \s+
  (?:
     (\d\d\d\d) |       # year
     (\d{1,2}):(\d{2})  # hour:min
            (?::(\d\d))?       # optional seconds
  )
  \s*$
       /x)

# If not that one, then this RegEx?
    ||

    # ISO 8601 format '1996-02-29 12:00:00 -0100' and variants
    (($yr, $mon, $day, $hr, $min, $sec, $tz) =
 /^
   (\d{4})              # year
      [-\/]?
   (\d\d?)              # numerical month
      [-\/]?
   (\d\d?)              # day
  (?:
        (?:\s+|[-:Tt])  # separator before clock
     (\d\d?):?(\d\d)    # hour:min
     (?::?(\d\d(?:\.\d*)?))?  # optional seconds (and fractional)
  )?                    # optional clock
     \s*
  ([-+]?\d\d?:?(:?\d\d)?
   |Z|z)?               # timezone  (Z is "zero meridian", i.e. GMT)
     \s*$
 /x)

# If not that one, then this RegEx?
    ||

    # Windows 'dir' 11-12-96  03:52PM
    (($mon, $day, $yr, $hr, $min, $ampm) =
        /^
          (\d{2})                # numerical month
             -
          (\d{2})                # day
             -
          (\d{2})                # year
             \s+
          (\d\d?):(\d\d)([APap][Mm])  # hour:min AM or PM
             \s*$
        /x)

# I guess not any. So bale!
    ||
    return;  # unrecognized format

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to