You need to apply lowercase to the strings before you compare, so it needs to be outside any \edef
here I have used \pdfstrcmp
to avoid having to define additional temp macros, this primitive is also available in other engines than pdftex, as \strcmp
.
This finds all but the last as equal
Image may be NSFW.
Clik here to view.
\documentclass{article}%%% Support command %%%\makeatletter\newcommand\compareStrings[2]{%\edef\tempA{\lowercase{\noexpand\ifnum0=\noexpand\pdfstrcmp {\noexpand\zap@space#1 \noexpand\@empty}% {\noexpand\zap@space#2 \noexpand\@empty}%}\relax}%\tempA \expandafter\@firstoftwo \else \expandafter\@secondoftwo \fi}\makeatother%%%%% End support commands %%%%\begin{document}\def\zz{T e sT}0: \compareStrings{tesT}{tesT}{1}{2}1: \compareStrings{test}{tesT}{1}{2}2: \compareStrings{\zz}{tesT}{1}{2}3: \compareStrings{testj}{tesT}{1}{2}\end{document}