Professional Web Applications Themes

Maybe Stupid RegEx Question - PERL Beginners

Hi I have two strings 0x1479ee und 0x1479fe. The strings a in $var1 and $var2. if I do: if ( $var2 =~ /\Q$var1\E/) It matches. how can I match an the string and not on each sign?...

  1. #1

    Default Maybe Stupid RegEx Question


    Hi

    I have two strings 0x1479ee und 0x1479fe.

    The strings a in $var1 and $var2.

    if I do:
    if ( $var2 =~ /\Q$var1\E/)

    It matches.

    how can I match an the string and not on each sign?

    Bastian Angerstein Guest

  2. #2

    Default Re: Maybe Stupid RegEx Question

    On Feb 12, 2004, at 7:34 AM, Bastian Angerstein wrote:
    >
    > Hi
    Hello.
    > I have two strings 0x1479ee und 0x1479fe.
    >
    > The strings a in $var1 and $var2.
    >
    > if I do:
    > if ( $var2 =~ /\Q$var1\E/)
    >
    > It matches.
    You sure about that?

    #!/usr/bin/perl

    my($var1, $var2) = ("0x1479ee", "0x1479fe");

    if ($var2 =~ /\Q$var1\E/) { print "They matched.\n"; }
    else { print "They didn't match.\n"; }

    __END__

    The above gives me "They didn't match." as expected.
    > how can I match an the string and not on each sign?
    The obvious answer is that they can't. Because of that, those
    variables probably don't contain what you think they contain.

    Hope that helps.

    James

    James Edward Gray II Guest

  3. #3

    Default Re: Maybe Stupid RegEx Question

    Bastian Angerstein wrote:
    > Hi
    >
    > I have two strings 0x1479ee und 0x1479fe.
    >
    > The strings a in $var1 and $var2.
    >
    > if I do:
    > if ( $var2 =~ /\Q$var1\E/)
    >
    > It matches.
    >
    > how can I match an the string and not on each sign?
    As someone else pointed out, I am surprised that you got a match...
    Just out of curiosity though, why not do this:

    if ( $var2 eq $var1 )

    Wouldn't that achieve what you want?

    Alan
    Alan Perry Guest

Similar Threads

  1. Stupid Question
    By Al Millstein in forum PERL Beginners
    Replies: 24
    Last Post: October 14th, 09:58 PM
  2. Stupid C# question Please help!
    By Will in forum ASP.NET General
    Replies: 3
    Last Post: August 9th, 02:26 PM
  3. a stupid question
    By Joe in forum PHP Development
    Replies: 2
    Last Post: July 24th, 10:37 AM
  4. Stupid Question, but need heLp
    By R1CH1E R1CH webforumsuser@macromedia.com in forum Macromedia Flash Sitedesign
    Replies: 2
    Last Post: July 19th, 01:46 PM
  5. Is this a stupid question?
    By Steve in forum ASP.NET General
    Replies: 6
    Last Post: July 17th, 06:01 PM

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