in reply to Re: macthing a word a in array of words
in thread macthing a word a in array of words

nice almost what i was looking for but thier seems to be a bug or it just how grep compares the words. $word doesnt exist on a letter or a of a $word exist. if you type in:noo than type in: oo it will say 'oo' exist. thanks for the replie. i try many more things and see what i can do. Thank you for the help YALL.
  • Comment on Re^2: macthing a word a in array of words

Replies are listed 'Best First'.
Re^3: macthing a word a in array of words
by Marshall (Canon) on Apr 03, 2011 at 23:22 UTC
    yes, the regex could be better. When dealing with user input, you should allow whitespace before and after the input. Some common idioms:
    s/^\s+//; #remove leading whitespace s/\s+$//; #remove trailing whitespace
    Now that whitespace is not a factor, for the match then anchor the search term to front and rear. /^dog$/; matches dog but not doggie let me know how you get along with those hints.