Quantcast
Channel: Trying to get \zap@space and \lowercase to work on string comparison - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 4

Trying to get \zap@space and \lowercase to work on string comparison

$
0
0

I am trying to do a non-case-sensitive check on two strings that may or may not have spaces in them. I have googled this and there is quite a lot of literature on either of these problems, but I can't seem to find much on doing both at once and I would ideally like a tex or latex solution that doesn't require external packages to be loaded (but this isn't required). I have something that seems like it should work using packages, and yet I can't determine why it doesn't. Here is the MWE.

\documentclass{article}\usepackage{ifthenx}%%% Support command %%%\makeatletter\newcommand\compareStrings[4]{%  \edef\tempA{\expandafter\zap@space \lowercase{#1} \@empty}  \edef\tempB{\expandafter\zap@space \lowercase{#2} \@empty}  \ifthenelse{\equal{\tempA}{\tempB}}{True}{False}  \tempA  \tempB}\makeatother%%%%% End support commands %%%%\begin{document}\compareStrings{test}{tesT}{1}{2}\end{document}

When you compile it, the \tempA and \tempB both display the exact same string, but the comparison itself returns False (the 3rd and 4th parameters in \compareStrings are suppose to be the true and false conditions, but I replaced them with words for testing purposes).

Any suggestions or explanations as to why it appears that the two strings are the same but aren't yielding "True" would be much appreciated. My first thought was that expansion would be to blame, but I would have expected edef to solve this problem, and clearly it is not.


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images