in reply to Regular Expression Problem

<code> tags are your friend.

That aside, you don't need to escape < and >, and \s is typically used to match whitespace, rather than having a literal space.

It would be helpful if you would post what it actually does, as other people would then have a better idea of what problems to look for.

Replies are listed 'Best First'.
Re: Re: Regular Expression Problem
by Wassercrats (Initiate) on Aug 29, 2002 at 03:15 UTC
    I know, but I was going crazy and tried things that I didn't think would matter (and they didn't!). I didn't try the solution in the third reply, but I think I missed something elsewhere in my script, which I'm going to look for now. I'm preparing myself to feel stupid.
Re: Re: Regular Expression Problem
by Wassercrats (Initiate) on Aug 29, 2002 at 03:48 UTC
    It looks like there is no update or comment option, so I guess I'll reply to you again. The following assignment:
    $remainder =~s/<.*?a.*?href.*?>//i;
    cuts nothing out, leaving the following in $remainder:
    <a href="government.php" ONMOUSEOUT="imgInact('img2')" ONMOUSEOVER="imgAct('img2')"><img border="0" src="gova.jp +g" width="60" height="46" name="img2" alt="Arkansas Government"></a>

    (unless I'm still missing something). I want only the </a> to remain. Am I doing something wrong?
      I tested it and it removed the <a> tag, leaving <img border="0" src="gova.jpg" width="60" height="46" name="img2" alt="Arkansas Government"></a>. Do you want the <img> tag removed as well?
        Sorry... I was on a public computer with my time running out and I didn't read my code carefully enough. I want to keep the img tag and everything after the one with href. I think I just have to replace that dot with something. I have to see if /s/S means any number of any character. I've heard conflicting stuff about it. Update... got my s stuff mixed up. Think I just need to add a /s modifier. Better yet, it sounds like I can use a module, but I've come this far, and of the code is right in front of me, I'll use it. Second update... Problem solved. The s modifier after the i modifier worked!
      Oh! There's a line-break in there! I need the alternative to . that will match a line brake!