Quantcast
Viewing all articles
Browse latest Browse all 4

Answer by David Carlisle for Trying to get \zap@space and \lowercase to work on string comparison

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.
enter image description here

\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}

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>