match a phrase

Hi,

I have a these sentences.

$sent1="Transactivation of wound-responsive genes containing the core sequence of the auxin-responsive element by a wound-induced protein kinase-activated transcription factor in tobacco plants.";

$sent2="I branching formation in erythroid differentiation is regulated by transcription factor.";

$query="transcription factor";(as a phrase)

I want to match $query.

I tried using regular expression but it is not working.I gave like this:-


if($sent1=~/\b$query\b/i)
{
    print "matched";
}

same way for sent2.

but it is not matching.

How to match this phrase?

with regards
vanitha

one way

if($sent1=~/$query/i)
{
    print "matched";
}

Hi,

I tried it is matching.I tried highlighting the term "transcription factor"

but it is not doing.

Here is the code:-

if($sent1=~/$query/i)
{
print "matched\n";
$sent1=~s/($query)/<spanstyle="background-color:#E1FF77">$1<\/span>/i;
print "<br>sentence1=$sent1<br>";
}

But it is not doing ?

how to solve this?

with regards
Archana

what is not doing ? you can at least show your output.
I don't know, here's my simulation of your problem

$sent1="Transactivation of wound-responsive genes containing the core sequence of the auxin-responsive element by a wound-induced protein kinase-activated transcription factor in tobacco plants.";

$sent2="I branching formation in erythroid differentiation is regulated by transcription factor.";

$query="transcription factor";
print "Original sent1: $sent1\n";;
if($sent1=~/$query/i)
{
    print "matched\n";
    $sent1=~s/($query)/<spanstyle="background-color:#E1FF77">$1<\/span>/i;
    print "<br>sentence1=$sent1<br>";
}

Here's my output.

# ./test1.pl
Original sent1: Transactivation of wound-responsive genes containing the core sequence of the auxin-responsive element by a wound-induced protein kinase-activated transcription factor in tobacco plants.
matched
<br>sentence1=Transactivation of wound-responsive genes containing the core sequence of the auxin-responsive element by a wound-induced protein kinase-activated <spanstyle="background-color:#E1FF77">transcription factor</span> in tobacco plants.<br>
#          

Hi,

But on the browser the phrase "transcription factor" is not getting highlighted.

here is th output

Original sent1: Transactivation of wound-responsive genes containing the core sequence of the auxin-responsive element by a wound-induced protein kinase-activated transcription factor in tobacco plants.

matched

sentence1=Transactivation of wound-responsive genes containing the core sequence of the auxin-responsive element by a wound-induced protein kinase-activated transcription factor in tobacco plants.

like that it should display on the browser.