# How to use { and } as delimiter instead of active character in this example

How to use { and } as delimiter instead of active caractere in this example ?

I'd like [360] [90] [7,2] as output of foreach command instead of this.

I need a string foreach compatible, splited on ; because arguments contain comma decimal separators.

\documentclass[french]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{tikz,xstring}

\begin{document}

\StrSubstitute{360;90;7,2}{;}{\},\{}[\ListeA]
\xdef\ListeA{\{\ListeA\}}

\ListeA

\foreach \x in \ListeA {[\x] }

\end{document}

-
It's not clear what you want to achieve. –  egreg Apr 28 at 16:43
@egreg true (I deleted my first comment:-) but actually the aim is to iterate through a ; separated list which has , in the items. (\{ is a red herring) –  David Carlisle Apr 28 at 16:45
I'd like [360] [90] [7,2] as output of foreach command, what else ;-) –  Tarass Apr 28 at 16:48
@Tarass you really should have stated that in the question, I had to read your code 5 times to guess what it was trying to do to guess that was your intention. If you post code that works, as in produces no error, but does not produce what you expected, then it is hard to help if you do not say what you expect. –  David Carlisle Apr 28 at 16:50
@DavidCarlisle I'm very sorry, it was obvious in my head, please sorry for the loss of time. –  Tarass Apr 28 at 16:58

This produces the desired output

\documentclass[french]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\def\foo#1{\xfoo#1;\relax;}
\def\xfoo#1;{\ifx\relax#1\else\xxfoo{#1}\expandafter\xfoo\fi}
\newcommand\xxfoo[1]{[#1]}
\begin{document}

\foo{360;90;7,2}

\end{document}


If you absolutely insist on using \foreach you can construct a list in teh first loop to loop over with \foreach but this is entirely pointless, anything you do in the body of the \foreach you could have done in the first loop.

This time with french babel's ;

\documentclass[french]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{tikz}
\begin{document}

\def\foo#1{\expandafter\expandafter\expandafter\zfoo\xfoo#1;\relax;}
\def\xfoo#1;{\ifx\relax#1\else,{#1}\expandafter\xfoo\fi}
\def\zfoo#1{}

\edef\zz{\foo{360;90;7,2}}

\foreach\x in \zz{
This is [\x]

}

\end{document}

-
It produces [360;90;7,2] –  Tarass Apr 28 at 17:04
@Tarass Of course not. –  egreg Apr 28 at 17:29
You are right, standalone your example works fine but I tried it directly in the file in wich it has to work, and in it, the résult is what I said. Maybe there is a package cobflict ? I use it in a middle a lots of things. –  Tarass Apr 28 at 17:37
@Tarass see updated example –  David Carlisle Apr 28 at 19:16
@DavidCarlisle Please see what ment in my proposition here tex.stackexchange.com/questions/73173/…. I am very sorry for the confusion I made and the loss of your time. Thank you for your help. –  Tarass Apr 29 at 4:43

Here's a solution with expl3:

\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
{
}

{
\seq_set_split:Nnn \l__tarass_addbrackets_seq { ; } { #1 }
}
\ExplSyntaxOff

\begin{document}
\end{document}


Several refinements are possible.

If you're using the French module for babel, you have to be aware of the fact that ; is a special character, because of the peculiar French habit of having a space before the semicolon.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{xparse}

\ExplSyntaxOn
\shorthandon{;}
{
}

{
\seq_set_split:Nnn \l__tarass_addbrackets_seq { ; } { #1 }
}
\shorthandoff{;}
\ExplSyntaxOff

\begin{document}

It gives me : [360;90;7,2] , I use \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} if it matters. –  Tarass Apr 28 at 17:13
@Tarass You're probably not saying the most important thing, that you're using French babel. It's very hard to help if you hide fundamental information: in French babel, the semicolon is a special character. –  egreg Apr 28 at 17:30
@Tarass No. I can't see babel loaded. That option just issues a warning, if \usepackage{babel} doesn't appear. –  egreg Apr 28 at 17:34
Sorry again, I thaught french instead of babel, time to sleep for me. Of course it works now. But the point is not backeted space separated result, but a foreach compatible string (for a complex use), here I gave just MWE of this use. I am very sorry for all this mysundertood and loss of your booth times. –  Tarass Apr 28 at 17:41