Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

foreach 1

Status
Not open for further replies.

cgiles82

MIS
Mar 31, 2005
3
US
foreach ($title)
{
$_=~s/\&/&#38/g;
$_=~s/\"/&#34/g;
$_=~s/\'/&#39/g;
}

The script replace any " in the title with &#34 but then the script replaces the & with &#38. Is there a work around?
 
try this:

$_ =~ s/\&([^\#])/\&#38$1/g;
$_ =~ s/\"/&#34/g;
$_ =~ s/\'/&#39/g;

See if that works.

AMA
 
well the code as posted is a bit odd:

foreach ($title)

normally you don't loop through a single scalar like that. This should work fine:

$title =~s/\&/&#38/g;
$title =~s/\"/&#34/g;
$title =~s/\'/&#39/g;

the order of the substitutions is the trick, and the above order should work fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top