or
samcarter
tikz
I have a document that heavily uses the old TikZ syntax for circles, ellipses and arcs:

```
\draw (0,0) circle (0.45);
\draw (0,0) ellipse (1.4 and 4);
\draw (0.65,0.61) arc(180:360:0.35 and 0.35); 
\draw (0.65,0.61) arc(180:360:0.35);
```

How can I use texstudios search and replace with regex to change it to the new syntax?

```
\draw (0,0) circle[radius=0.45];
\draw (0,0) ellipse[x radius=1.4, y radius=4];
\draw (0.65,0.61) arc[start angle=180, end angle=360, x radius=0.35, y radius =0.35]
\draw (0.65,0.61) arc[start angle=180, end angle=360, radius=0.35];
```
Top Answer
samcarter
The following search and replace terms will update the syntax

### Circle:

- search: `circle \(([^\)]*)\)`
- replace `circle[radius=\1]`

### Ellipse

- search: `ellipse \(([^\)]*) and ([^\)]*)\)`
- replace: `ellipse[x radius=\1, y radius=\2]`

### Elliptical arc 

- search `arc\(([^\)]*):([^\)]*):([^\)]*) and ([^\)]*)\)`
- replace `arc[start angle=\1, end angle=\2, x radius=\3, y radius =\4] `

(if you have both elliptical and circular arcs in the same document, do the elliptical arcs first)

### Circular arc

- search `arc\(([^\)]*):([^\)]*):([^\)]*)\)`
- replace `arc[start angle=\1, end angle=\2, radius=\3] `

(Don't forget to activate the `Reg` and `\1` buttons in texstudio to use this syntax)

![Screen Shot 2020-01-02 at 22.13.45.png](/image?hash=f7ca2611f9a33ab3f4c35380d098912b2cb265534c94bba79bc0cf0306a6d293)
regex to replace TikZ's old circle, ellipse and arc syntax with new one
samcarter replying to Skillmon
Done! Thanks for the suggestion!
Skillmon
@samcarter Maybe you should change the order of "Elliptical arc" and "Circular arc" in your answer, that would be less error prone.
marmot replying to Skillmon
It is very common among marmots.
Skillmon replying to marmot
what's with that late obsession with honey liquor of yours?
marmot replying to Skillmon
Only fast beings get blessed with honey liquor. ;-)
Skillmon replying to samcarter
IIRC, he's also faster than I am during summer.
samcarter replying to Skillmon
The question is: Despite or because it is hibernation season?
Skillmon replying to samcarter
As always @marmot was faster.
samcarter replying to marmot
Thanks!
marmot replying to samcarter
The old syntax equivalent is `\draw (0.65,0.61) arc(180:360:0.35 and 0.35);` or just `\draw (0.65,0.61) arc(180:360:0.35);`.
samcarter replying to Skillmon
What is the old/new arc syntax? I only know `\draw[start angle=180, end angle=360, x radius=0.35, y radius=0.35] (0.65,0.61) arc;`
samcarter replying to Skillmon
Lucky me I just have boring numbers in my packages :) 
Skillmon
@samcarter your regular expressions will fail for input like `circle ({(5+4)/2})`. Parsing TeX with regular expressions is hard :) Also a regular expression for old `arc` -> new `arc` is missing.