Skip to main content
Improved formatting
Source Link
m_goldberg
  • 108.2k
  • 16
  • 104
  • 259

You also need InputForm if you want to convert \[Pi]π to PiPi.

If you want parentheses, then

2 \[Pi]π/5 // ToString[#, InputForm] & // StringReplace[#, "/" :> "--"] &

"(2*Pi)--5"

Elseor else

2 \[Pi]π/5 // ToString[#, InputForm] & // 
  StringReplace[#, {"/" :> "--", "(" :> "", ")" :> ""}] &

"2*Pi--5"

You also need InputForm if you want to convert \[Pi] to Pi

If you want parentheses

2 \[Pi]/5 // ToString[#, InputForm] & // StringReplace[#, "/" :> "--"] &

"(2*Pi)--5"

Else

2 \[Pi]/5 // ToString[#, InputForm] & // 
 StringReplace[#, {"/" :> "--", "(" :> "", ")" :> ""}] &

"2*Pi--5"

You also need InputForm if you want to convert π to Pi.

If you want parentheses, then

2 π/5 // ToString[#, InputForm] & // StringReplace[#, "/" :> "--"] &

"(2*Pi)--5"

or else

2 π/5 // ToString[#, InputForm] & // 
  StringReplace[#, {"/" :> "--", "(" :> "", ")" :> ""}] &

"2*Pi--5"

Source Link
Bob Hanlon
  • 162.7k
  • 7
  • 81
  • 205

You also need InputForm if you want to convert \[Pi] to Pi

If you want parentheses

2 \[Pi]/5 // ToString[#, InputForm] & // StringReplace[#, "/" :> "--"] &

"(2*Pi)--5"

Else

2 \[Pi]/5 // ToString[#, InputForm] & // 
 StringReplace[#, {"/" :> "--", "(" :> "", ")" :> ""}] &

"2*Pi--5"