# Changing case of URL in \href argument

I would like to write a macro similar to the \href command from the hyperref package, but which takes a single argument. The URL is generated by making the argument lowercase.

Here is a minimal example:

\documentclass{article}
\usepackage{hyperref}

\begin{document}
\end{document}


However, the \lowercase command is not expanded, and the link points to www.\lowercase{MyURL}.com. Is there a way to solve this problem?

-

\newcommand\mylink[1]{\lowercase{\href{www.#1.com}}{#1}}


will work.

As requested in comments a more complicated example:

\documentclass{article}
\usepackage{hyperref}

\newcommand\mymail[2]{%
\lowercase{\def\tmpa{#1}}%
\uppercase{\def\tmpb{#2}}%
\href{mailto:\tmpa.\tmpb}{#1.#2}}

\begin{document}

should make no difference unless something else redefines it add \show\mylink after \begin{document} and tex will stop and show you the definition, if it isn't your definition something else is defining it. – David Carlisle Jan 28 '13 at 11:31
Surprising that it works. But out of curiosity: How to expand stuff in \href? I might want to do something like: \href{mailto:\lowercase{#1}.\uppercase{#2}}{#1.#2} – Frederick Nord Feb 11 '13 at 17:07
Things expand automatically in \href: the problem is that \lowercase is not an expandable command, I'll add code to the answer for this – David Carlisle Feb 11 '13 at 17:36