Professional Web Applications Themes

Regex help (? as delimiter) - PERL Miscellaneous

Lawrence Tierney wrote: > I'm trying to match the following string: > > (OS/S 140-126484/EN) > > $data=~/^\(\d{2}\/[A-Z] \d{1,3}-\d{3,6}\/EN\)$/; # Works okay --------------^ No it doesn't. > $data=~?^\(\d{2}/[A-Z] \d{1,3}-\d{3,6}/EN\)$?; # Doesn't match Exchange \d for \w and it matches. -- Gunnar Hjalmarsson Email: [url]http://www.gunnar.cc/cgi-bin/contact.pl[/url]...

  1. #1

    Default Re: Regex help (? as delimiter)

    Lawrence Tierney wrote:
    > I'm trying to match the following string:
    >
    > (OS/S 140-126484/EN)
    >
    > $data=~/^\(\d{2}\/[A-Z] \d{1,3}-\d{3,6}\/EN\)$/; # Works okay
    --------------^

    No it doesn't.
    > $data=~?^\(\d{2}/[A-Z] \d{1,3}-\d{3,6}/EN\)$?; # Doesn't match
    Exchange \d for \w and it matches.

    --
    Gunnar Hjalmarsson
    Email: [url]http://www.gunnar.cc/cgi-bin/contact.pl[/url]

    Gunnar Hjalmarsson Guest

  2. #2

    Default Re: Regex help (? as delimiter)

    On 23 Jul 2003 09:55:27 -0700
    [email]lawrence.tierneybipcontracts.com[/email] (Lawrence Tierney) wrote:
    >
    > Hello,
    >
    > I've got something going on with a regex which I don't quite
    > understand. I'm trying to match the following string:
    >
    > (OS/S 140-126484/EN)
    >
    > $data=~/^\(\d{2}\/[A-Z] \d{1,3}-\d{3,6}\/EN\)$/; # Works okay
    >
    no, it doesn't match. should that first \d be \D?
    >
    > $data=~?^\(\d{2}/[A-Z] \d{1,3}-\d{3,6}/EN\)$?; # Doesn't match
    >
    right, it doesn't match.
    >
    > I tried using the ? as my delimiter to prevent having to escape the
    > forward slashes.
    >
    as for using ? as a regexp delimiter, it's
    allowed but it's an odd choice, IM(very)HO.





    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    drop the .thetenant to get me via mail
    John Strauss Guest

  3. #3

    Default Re: Regex help (? as delimiter)

    On Wed, 23 Jul 2003, John Strauss wrote:
    >On 23 Jul 2003 09:55:27 -0700
    >lawrence.tierneybipcontracts.com (Lawrence Tierney) wrote:
    >>
    >> Hello,
    >>
    >> I've got something going on with a regex which I don't quite
    >> understand. I'm trying to match the following string:
    >>
    >> (OS/S 140-126484/EN)
    >>
    >> $data=~/^\(\d{2}\/[A-Z] \d{1,3}-\d{3,6}\/EN\)$/; # Works okay
    >>
    >no, it doesn't match. should that first \d be \D?
    >
    >>
    >> $data=~?^\(\d{2}/[A-Z] \d{1,3}-\d{3,6}/EN\)$?; # Doesn't match
    >>
    >right, it doesn't match.
    >
    >>
    >> I tried using the ? as my delimiter to prevent having to escape the
    >> forward slashes.
    >>
    >as for using ? as a regexp delimiter, it's
    >allowed but it's an odd choice, IM(very)HO.
    Yes, it's allowed, but it does something different than any other regex
    delimiter. It only matches ONCE successfully inbetween calls to the
    reset() function.

    --
    Jeff Pinyan RPI Acacia Brother #734 2003 Rush Chairman
    "And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
    years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
    Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)

    Jeff 'japhy' Pinyan Guest

Similar Threads

  1. Delimiter for string..
    By Ajit P Singh in forum PERL Beginners
    Replies: 3
    Last Post: February 5th, 01:16 PM
  2. Splitting and keeping the delimiter
    By Sandman in forum PERL Miscellaneous
    Replies: 9
    Last Post: September 12th, 12:40 PM
  3. [PHP] Delimiter WITHOUT lots of IF's
    By Cesar Aracena in forum PHP Development
    Replies: 7
    Last Post: August 19th, 07:04 PM
  4. Delimiter WITHOUT lots of IF's
    By Cesar Aracena in forum PHP Development
    Replies: 2
    Last Post: August 19th, 03:33 AM
  5. Delimiter Split
    By Mark Fox in forum ASP.NET General
    Replies: 2
    Last Post: August 11th, 07:19 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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