SPUG: Re: regex problems...

Sean seanow0 at email.msn.com
Fri Oct 1 13:38:53 CDT 1999

Eww.  sorry for the HTML problems.

Actually I answered my own question -- I need to escape any characters in
the variable I'd need to in the reg ex.

However, once I got that far, I hit up against another question:

why won't this work?
$code =~ s/($x)(..)($y)/$y$2$x/gsi;

Even if I type in plain text that I know is there, I get a false result.  do
I need to do anything special when mixing variables & text in an expression?
BTW, I worked around this by assigning a variable the value ".." and using
that instead, that seems to work ok.

thanks again.

----- Original Message -----
From: Sean
To: spug-list at pm.org
Sent: Friday, October 01, 1999 11:11 AM
Subject: regex problems...

I don't pretent to be an expert at Perl, so hopefully this isn't a silly
question everyone but me knows:

I'm doing some search & replace functions, and I've assigned some big
strings of HTML to variables, and I've got a question about the s///

If I say:

$snip='<a href="http://blah.foo.com/index.htm" class="style"';
$code =~ s/$snip/[replacement/gsi;

$code =~ s/<a href="http://blah.foo.com/index.htm"

I know example 2 is wrong and I need to escape a few characters, but why
won't example 1 work?  If I change $snip to ="blah" then the expression will
return true, but the full html variable always returns false, even though I
can see that exact line in my code.  Can anyone tell me what I'm doing


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    POST TO: spug-list at pm.org        PROBLEMS: owner-spug-list at pm.org
 Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
 SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe
        Email to majordomo at pm.org: ACTION spug-list your_address

More information about the spug-list mailing list