in reply to finding whole words in a string

Use the \b This match "the blank" the nothing after and before your word:
$string =~ /\bindia\b/i;
(Thanks Fletch)

Hopes
$_=$,=q,\,@4O,,s,^$,$\,,s,s,^,b9,s, $_^=q,$\^-]!,,print

Replies are listed 'Best First'.
Re: Re: finding whole words in a string
by Fletch (Bishop) on May 07, 2002 at 19:00 UTC

    Technically it doesn't match `the blank'. As perlre states it matches at a `\w\W' or '\W\w' transition (it doesn't match anything literally as it's zero width, just at a point where the previous character is \w and the next is \W (or vice versa)).

      Sure Fletch, I was not clear. I would had to say:

      \b matches the nothing after and before ...


      Hopes
      $_=$,=q,\,@4O,,s,^$,$\,,s,s,^,b9,s, $_^=q,$\^-]!,,print