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

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

$
0
0

An expl3 solution. Here, I use the fact that \tl_map_function:nN will 'eat' spaces, and do proper case folding rather than lower casing (see the Unicode docs for the reasons that this is important):

\documentclass{article}\usepackage{expl3,xparse}\ExplSyntaxOn\NewExpandableDocumentCommand \compareStrings { m m +m +m }  {    \str_if_eq:eeTF % \str_if_eq_x:nnTF in older code      { \tl_map_function:fN { \str_foldcase:n {#1} } \use:n }      { \tl_map_function:fN { \str_foldcase:n {#2} } \use:n }      {#3} {#4}  }\cs_generate_variant:Nn \tl_map_function:nN { f }\ExplSyntaxOff\begin{document}\compareStrings{test}{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>