Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!sdd.hp.com!uakari.primate.wisc.edu!aplcen!jhunix!barrett From: barrett@jhunix.HCF.JHU.EDU (Dan Barrett) Newsgroups: comp.text.tex Subject: Grabbing substrings? Keywords: strrchr() Message-ID: <8487@jhunix.HCF.JHU.EDU> Date: 28 May 91 20:29:29 GMT Followup-To: poster Distribution: usa Organization: The Johns Hopkins University - HCF Lines: 27 I want to write a LaTeX or TeX macro that expands to a substring of its argument. For example, a macro \basename{} would take a UNIX filename as an argument: \basename{/usr/local/bin/foobar} and expand to: foobar Can TeX/LaTeX isolate substrings in a macro argument? The rule I want to embody is: "If the argument has a '/' character, then expand to the string immediately following the last '/'. Otherwise, expand to the entire argument." Please respond by e-mail only -- thanks! Dan //////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ | Dan Barrett, Department of Computer Science Johns Hopkins University | | INTERNET: barrett@cs.jhu.edu | | | COMPUSERVE: >internet:barrett@cs.jhu.edu | UUCP: barrett@jhunix.UUCP | \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/////////////////////////////////////