[PHP] Q on Regular Expressions

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Re: [PHP] Q on Regular Expressions

    * Thus wrote jsWalter (jsWalter@torres.ws):
    > 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.
    have you looked at strtotime()?
    [url]http://php.net/strtotime[/url]

    The Date formats it can find are defined here:
    [url]http://www.gnu.org/manual/tar-1.12/html_chapter/tar_7.html[/url]


    Those regex's look like a nightmare, like they usually do :)
    >
    > # 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)
    >

    Curt
    --
    "I used to think I was indecisive, but now I'm not so sure."
    Curt Zirzow Guest

  2. Similar Questions and Discussions

    1. RE : RE : Regular expressions
      I think I begin to understand... I begin by fetching the results of the ps -efA command and split it into many variables ($uid, $pid, etc.) ...
    2. PHP regular expressions
      Hello, I am writing an elearning software with php. I need a script to recognize any inut of the type ab,aabb,aaabbb,aaaabbbb..... And so on....
    3. [PHP-DEV] PHP regular expressions
      Hello. In regex/utils.h there is a definition for DUPMAX: #ifdef _POSIX2_RE_DUP_MAX #define DUPMAX _POSIX2_RE_DUP_MAX #else #define DUPMAX 255...
    4. Help with regular expressions.
      Apples and Oranges: I think your format string is wrong, try: {0:d} "Pablo Pecora" <pablo.pecora@itau.com.ar> wrote in message...
    5. help with regular expressions
      Hello, just getting grips with Perl and RE, but need your help. I am trying to open a file, print its contents to a textbox, but extract...
  3. #2

    Default Re: [PHP] Q on Regular Expressions

    Thanks for the pointer, but this only deals with date/time in EPOCH range.

    I'm trying to handle dates pre-epoch.

    Thanks

    Walter



    "Curt Zirzow" <php-general@zirzow.dyndns.org> wrote in message
    news:20030917211347.GF4251@bagend.shire...
    > * Thus wrote jsWalter (jsWalter@torres.ws):
    > > 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.
    >
    > have you looked at strtotime()?
    > [url]http://php.net/strtotime[/url]
    >
    > The Date formats it can find are defined here:
    > [url]http://www.gnu.org/manual/tar-1.12/html_chapter/tar_7.html[/url]
    >
    >
    > Those regex's look like a nightmare, like they usually do :)
    >
    > >
    > > # 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)
    > >
    >
    >
    > Curt
    > --
    > "I used to think I was indecisive, but now I'm not so sure."
    Jswalter Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139