develooper Front page | perl.macperl.anyperl | Postings from October 2006

Let perl replase words

Thread Next
From:
Eelco Alosery
Date:
October 7, 2006 11:59
Subject:
Let perl replase words
Message ID:
DAFD6FE0-9DAF-4458-A114-E41877AB85E5@multi-graphics.nl
Hello,

I have a small, (maby big) problem.

Im writing a search script for my site, and wand to do some replacing  
of words.

I have a string that contains for example this :
Test this is a smal test script line.

Now i have a search patern :
test

What i want to do is this.
Test and test must be replased by <b>Test</b> and <b>test</b>

Thus al (case insensative) matches to test must be converted to bold  
words.

I have tested a lot, and the best result sovar is this code :
$head =~ s/$replace/<u>$replace<\/u>/gi;

But this code replases Test to <b>test</b> it is realy convertet to  
the original search patern.

Any help whit this is very welcome.

Thanks,
Eelco Alosery

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About