skazat has asked for the wisdom of the Perl Monks concerning the following question:
Howdy,
I'm trying to unescape text that may mean something special when this text is in a variable that's being used in a regular expression, here's an example:
my $foo = "[hello]"; my $bar = "agabaga[hello]zoomzoomzoom"; my $buzz = "goodbye"; $bar =~ s/$foo/$buzz/gi; print "\n$bar\n";
this will faithfully print out:
agabagagoodbyegoodbyegoodbyegoodbyegoodbyezgoodbyegoodbyemzgoodbyegoodbyemzgoodbyegoodbyem
Which isn't exact.y what I wanted, I just wanted hello to be replaced with goodbye. I'm using lil psuedo tags like this for a small templating system, I really like brackets like this, and it seems that there should be an easy way to escape the stuff that the variable holds.
Does anyone know how?
btw, has anyone realized the search on this site is useless? You receive about 100 results that don't help ya out much.
-justin simoni
!skazat!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regular Expressions and Variables
by japhy (Canon) on Feb 13, 2001 at 03:34 UTC | |
|
Re: Regular Expressions and Variables
by MeowChow (Vicar) on Feb 13, 2001 at 04:41 UTC | |
|
Re: Regular Expressions and Variables
by mikfire (Deacon) on Feb 13, 2001 at 03:36 UTC | |
by skazat (Chaplain) on Feb 13, 2001 at 03:45 UTC | |
|
Re: Regular Expressions and Variables
by lemming (Priest) on Feb 13, 2001 at 03:33 UTC | |
|
Re: Regular Expressions and Variables
by wardk (Deacon) on Feb 13, 2001 at 03:40 UTC | |
by skazat (Chaplain) on Feb 13, 2001 at 03:53 UTC | |
by chipmunk (Parson) on Feb 13, 2001 at 04:20 UTC | |
by skazat (Chaplain) on Feb 13, 2001 at 08:58 UTC |