How to define a macro which takes a string made by number and an optional letter and then branches on the basis on the letter?
Since this is an extension of an existing package, it is preferable not to use any package or LaTeX3; furthermore, since the syntax is not defined yet, you could implement the answer with the letter following or preceding the number, with any separator you want (none is better).
\documentclass{article}
\def\myparse#1{...} % or \newcommand{\myparse}[1]{...}
% Suppose the letter has to be after the number with no separator,
% and the command branches on letters "b", "m", "e" to represent
% the beginning, middle or end of a year.
\begin{document}
\myparse{2004b} % Should print "Beginning of 2004"
\myparse{2005} % Should print "2005"
\myparse{2005m} % Should print "2005" too
\myparse{2006e} % Should print "End of 2006"
\end{document}
xparse
and orxstring
are quite stable packages which can be used basically everywhere?pgf
, but there is no imaginable need to use macros as arguments.