I have to mildly disagree. I agree that /^$bar$/ is a dumb regex, but often string literal regexes without either the ^ or the $ are a perfectly reasonable idea.
Now it may be the sort of scripts I've been writing recently, but I almost never find an occasion to use the "eq" operator. And it isn't just that I want case insensitive matches. It's most often whitespace or added junk characters. If I'm trying to match the string "foobar" I don't really care if it is actually "foobar ". Or if I'm looking for the string "no such file or directory" I don't care if I hit "no such file or directory at line 26 of foobar.pl". So I'll use /^no such file or directory/i without a second thought.
So I'm not really sure how strict you were being in your definition of patterns (personally, when I read the word "pattern" I think of masses of '\'ed characters), but I often find regexes a nice fit for matching plain old strings with a bit of leeway. I don't know if I'm interpreting you as being more draconian than you intended, but there is a place for regexes in certain types of string comparison.
But /^$bar$/ really is dumb. Although my personal favorite for stupid regexes is /.*$bar.*/
If you have any trouble sounding condescending, find a Unix user to show you how it's done.
- Scott Adams
In reply to Re: Regexes Are Not For String Comparison
by DeusVult
in thread Regexes Are Not For String Comparison
by japhy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |