The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
convert phrase fredao Shell Programming and Scripting 4 04-24-2008 11:34 AM
Dont Know How to Phrase the Title barney34 Shell Programming and Scripting 1 12-12-2006 01:36 PM
Remove duplicate phrase kesu2k Shell Programming and Scripting 6 10-17-2006 01:34 PM
if statement to match * sivasenthil_k UNIX for Dummies Questions & Answers 3 09-20-2006 08:39 AM
Searching for a specific phrase on Unix server mmcaleer UNIX for Dummies Questions & Answers 1 02-07-2005 01:18 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-13-2008
Registered User
 

Join Date: Sep 2007
Posts: 34
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:-

Code:
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
Reply With Quote
Forum Sponsor
  #2  
Old 01-14-2008
Registered User
 

Join Date: Sep 2006
Posts: 1,580
one way
Code:
if($sent1=~/$query/i)
{
    print "matched";
}
Reply With Quote
  #3  
Old 01-14-2008
Registered User
 

Join Date: Sep 2007
Posts: 34
Quote:
Originally Posted by ghostdog74 View Post
one way
Code:
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:-
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
Reply With Quote
  #4  
Old 01-14-2008
Registered User
 

Join Date: Sep 2006
Posts: 1,580
what is not doing ? you can at least show your output.
I don't know, here's my simulation of your problem
Code:
$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.
Code:
# ./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>
#
Reply With Quote
  #5  
Old 01-15-2008
Registered User
 

Join Date: Sep 2007
Posts: 34
Quote:
Originally Posted by ghostdog74 View Post
what is not doing ? you can at least show your output.
I don't know, here's my simulation of your problem
Code:
$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.
Code:
# ./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

Code:
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.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:09 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0