Gossamer Forum
Home : General : Perl Programming :

alone / in a phrase

Quote Reply
alone / in a phrase
How can I tell the script to get a word in a phrase.

I would like to get the word "pizza" either alone or in a phrase like "I eat PIZZA"

if ($value eq "pizza") works only if the value is exactly "pizza". I must foresee something *before* and *after* the word.

Also I would like to read lowercase and uppercase in the same way.

Thanks in advance.
Quote Reply
Re: alone / in a phrase In reply to
Might want to read up on pattern matching.
perldoc perlop

try

if ($value =~ /pizza/i)

-- Gordon --


------------------
$blah='82:84:70:77';
print chr($_) foreach (split/:/,$blah);

Quote Reply
Re: alone / in a phrase In reply to
if ($value =~ /\bpizza\b/i){

to match exact word "pizza" in sentences.
------------------
Turk Scripts
turkiyem.com/turkscripts

[This message has been edited by sumengen (edited December 05, 1999).]