in reply to Re: Regular Expression Problem
in thread Regular Expression Problem

The problem isn't where I want to print the "&" or not but where the string matchs. See the ex;
If you do this:
my $test = "A C Test"; if($test=~s/\bA C Test\b/A&C Test/){print "<b>$test</b>";}

It will work. But if the value is coming from something like this:
my $test_name = $in{'test_name'};
It will nor work.
That's my problem! Tks...

Replies are listed 'Best First'.
Re: Regular Expression Problem
by skx (Parson) on Mar 29, 2004 at 14:53 UTC

    This is why I said "Have you verified that your text contains what you think it does?".

    Print it out and see!

    In the code you give above, for example, you're testing against $test - but getting the input into $test_name - which isn't being used!

    Steve
    ---
    steve.org.uk
      I think that problem starts even before.
      I have a link like:
      <a href=\"applic.pl?trans=edit&action=edit&name=$name>
      The value from the header isn't parsing the "&".
Re: Re: Re: Regular Expression Problem
by dawn (Novice) on Mar 29, 2004 at 15:00 UTC
    Have you tried using chomp to remove any trailing newlines? e.g. my $string = chomp($myinput);
      I got the solution for this problem
      I encoded the "&" on the url like "%26".
      After I coded this to do the translation
      if($name=~/(.*)&(.*?)/) { $name=~s/(.*)&(.*?)/$1%26$2/; print $name; } else { print $name; }

      Thank you for all your help!
      I think that problem starts even before.
      I have a link like:
      <a href=\"applic.pl?trans=edit&action=edit&name=$name>
      The value from the header isn't parsing the "&".