Saturday, August 6, 2011

XSLT 1.0/XPath 1.0 Case-Insensitive String Match

With XPath 2.0, you can use fn:matches('My TeSt String','test', 'i') to do case-insensitive.

With XPath 1.0, here's how:

contains(translate('My TeSt String','ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'test')

This translate function maps letters and essentially turns uppercase letters into lowercase letters.

1 comment:

  1. There are certain things I don't want to joke about. If it's about somebody else, it's fine.If it's about me, I think it's totally insensitive! See the link below for more info.

    #insensitive
    www.ufgop.org

    ReplyDelete