in reply to Re: Comparing strings case insensitive
in thread Comparing strings case insensitive

So the lower cased string comparison is more robust than the regexp?
  • Comment on Re^2: Comparing strings case insensitive

Replies are listed 'Best First'.
Re^3: Comparing strings case insensitive
by Fletch (Bishop) on Sep 12, 2008 at 21:39 UTC

    Yes, because lc "alligatorz" eq lc "a.*z" will properly compare as unequal, whereas "alligatorz" =~ /^a.*z$/i incorrectly (for what you're trying to do) will match. That's what I mentioned about robustness, but again with the proper application of \Q that wouldn't be an issue.

    That being said, I'd still use the lc $x eq lc $y version vice the \Q-ified regexp match as it's more explicit that you're doing a case insensitive comparison between fixed strings.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re^3: Comparing strings case insensitive
by kyle (Abbot) on Sep 12, 2008 at 21:28 UTC

    So the lower cased string comparison is more robust than the regexp?

    Yes.