Before you scroll down to my code, please notice that just because this code works does not mean that it is a good way to do so.
In general, there is a data structure called "comma list". Comma list plays a role in LaTeX-programming. For example while using geometry we may say \usepackage[top=2cm,left=3cm]{geometry}. In this case, top=2cm,left=3cm is a comma list that contains two items: top=2cm and left=3cm. (They are separated by comma, hence the name.) (And then top=2cm is interpreted as a key-value pair: top the key and 2cm the value.)
Similarly, your notation is indeed a "nested comma list". The outer level is called "stack" with / being its separator. The inner level is called "layer" with - being its separator. So all you need to do is to mimic this, this or this to iterate over your nested slash-dash list.
Since your request is relatively simple (only letters and numbers involved), a short TeX code is enough to illustrate how to deal with your comma list nested slash-dash list:
- First of all
\CE takes an argument, the complete list, and passes it to CEii.
\CEii takes two arguments separating by /. So the first argument is the substring before the first /. The substring after becomes the second argument. For example Co-Fe-B/MgO/Co-Fe-B is divided into Co-Fe-B and MgO/Co-Fe-B.
- Now the first argument
Co-Fe-B should be the first layer, pass it to \Ce.
- If the second argument is not empty, then there are more layers coming. Insert a
\newslash.
- Treat the second argument, the other layers
MgO/Co-Fe-B, as a new list and start from the beginning. (MgO/Co-Fe-B becomes MgO and Co-Fe-B. Both of them are passed to \Ce in sequence. Another \newslash is inserted between them.)
\Ce and Ceii do the same job as CE and CEii. The difference is that it divides the string according to - and inserts \newdash. (Co-Fe-B becomes Co, Fe and B.) And pass these elements to \ce in sequence.
- (MgO is not an element ... my bad)
- It is your job to redefine
\newskash and \newdash.

\documentclass{article}
\usepackage{mhchem}
\begin{document}
\def\newslash{///}
\def\newdash{---}
\newif\ifmoreelements
\newif\ifmorelayers
\def\Ce#1{%
\def\templayer{#1}%
\loop%
\expandafter\Ceii\templayer-=%
\expandafter\ce\expandafter{\tempfirstelement}%
\ifmoreelements%
\newdash%
\expandafter\Cei\tempotherelements=%
\repeat}
\def\Cei#1-={%
\def\templayer{#1}}
\def\Ceii#1-#2={%
\def\tempfirstelement{#1}\def\tempotherelements{#2}%
\ifx\tempotherelements\empty\moreelementsfalse\else\moreelementstrue\fi}
\def\CE#1{%
\def\tempstack{#1}%
\loop%
\expandafter\CEii\tempstack/+%
{\expandafter\Ce\expandafter{\tempfirstlayer}}%
\ifmorelayers%
\newslash%
\expandafter\CEi\tempotherlayers+%
\repeat}
\def\CEi#1/+{%
\def\tempstack{#1}}
\def\CEii#1/#2+{%
\def\tempfirstlayer{#1}\def\tempotherlayers{#2}%
\ifx\tempotherlayers\empty\morelayersfalse\else\morelayerstrue\fi}
\CE{Ta/Cu/Ta/Cu/Co-Fe-B/MgO/Co-Fe-B/Ta/Ru/Au}
\end{document}
About Good way
Sometimes I hear people saying that we should never use \def. And the reason is clear: using TeX syntax is in some sense dangerous. For example if one says \CE{-==-+//+-==-}, it will not work as expected. Besides, there are some appearance issues. For example \CE{ Ta // Cu } will call \ce{ Ta } and \ce{ Cu } with spaces while \CE should ignore all spaces around commas.
Nevertheless, it is all up to you. If you KNOW your code will never be like \CE{-==-+//+-==-} and you do like this simple way, then use it. But If you are seeking a way that is powerful and safe, say \DeclareCommaListParser\CE[/][-]{blahblahblah}, then give xparse a chance.
For me, xparse is complicated so far. However if someday LaTeX3 released and those commands are well-documented, I may not answer questions with def anymore.
\slashinstead of/if you want to allow a linebreak after a slash. If you write\ce{Co}-\ce{Fe}-\ce{B}you can avoid the bond problem (but of course you'll have even more\ces). – cgnieder Sep 18 '14 at 22:06