I have a string like this.
$str="The astrocyte profile might contribute to the identification of possible therapies in profiles profiling and profiled als.";
Lets consider for example:
a)If user enters the term profile* it should highlight profile,profiles only.
b)If user enters the prof* then it should highlight profile,profiles,profiling,profiled.
I have written code like this:
$query="profile*" or "prof*";
$regex=$query;
$regex =~ s/$/.*?/g;
if($str=~/$regex/i)
{
print "\n matched \n";
$str=~s/(\b$regex\b)/<span style="background-color:#E1FF77">$1<\/span>/img;
print "\nmatched sentence = $str \n";
}
I have one problem whatever the query(i.e prof* or profile*) it is highlighting all the words(i.e profile,profiles,profiling,profiled).
How to check that it should highlight given query only i.e (if user enters profile* it should highlight profile,profiles only and if user enters prof* it should highlight profile,profiles,profiling,profiled).
With regards
Vanitha