Maybe Stupid RegEx Question

Ask a Question related to PERL Beginners, Design and Development.

  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. Similar Questions and Discussions

    1. Stupid Question
      For as long as I've been doing Elements, I'm embarassed to ask. I've created an oval shaped image. I want to insert it into a web page as an oval...
    2. really really stupid question
      So I made an animation for my website and I want it to run it ionce n the beginning when people go to the home page. Also, I'd like a little box...
    3. Stupid C# question Please help!
      I'm used to writing my code in VBscript but I have to do this project in C#. I've written some functions on my ASP.Net page and I'm getting an...
    4. a stupid question
      how to check the filetype of remote file because is_dir(), is_file() can't work on remote file thx a lot
    5. Stupid Question, but need heLp
      I can't insert a background into my fLash form, how do I do it?
  3. #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

  4. #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

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