# How do I replace a double asterisk Noncommutative multiplication symbol in an output?

For a better overview in my output, I would like to replace ** with nothing. Since

foobar /. ** -> ""


does not work I ask for help.

The ** is the Noncommutative multiplication.

Reference: NonCommutativeMultiply

Thanks!

• Unless you are talking about the string "**", the expression ** is not a valid Wolfram Language expression, henceforth it will never be an output of any expression. What language are you using? – Fortsaint Jul 10 '19 at 8:38
• Can you give an example input in which you'd like the asterisks removed? By the looks of it, you're working with strings, in which case you need StringReplace or StringDelete and specify appropriate string pattern you want to delete: reference.wolfram.com/language/tutorial/StringPatterns.html – Sjoerd Smit Jul 10 '19 at 8:38
• I am using the noncommutative multiplication. And since my output is big I just want to leave it out after calculation. Since I know its an multiplication reference.wolfram.com/language/ref/NonCommutativeMultiply.html – BlackPhoton Jul 10 '19 at 8:44
• user66499, i suggest you add the information in your comment to your question. – kglr Jul 10 '19 at 9:01

foobar = c ** b ** a;

foobar /. NonCommutativeMultiply[a__] :> Infix[NonCommutativeMultiply[a], "\[InvisibleTimes]"]


• Thanks for your help! – BlackPhoton Jul 10 '19 at 8:57
• @user66499, my pleasure. Welcome to mma.se. – kglr Jul 10 '19 at 9:00

Stealing from @kglr, but taking advantage of Format instead of ReplaceAll

expression=c**b**a
(* c**b**a *)

FullForm[expression]
(* NonCommutativeMultiply[c,b,a]*)

Unprotect[NonCommutativeMultiply];
Format[NonCommutativeMultiply[k__]]:=Infix[NonCommutativeMultiply[k], "\InvisibleTimes]"];
Protect[NonCommutativeMultiply];

expression
(* c\[InvisibleTimes]b\[InvisibleTimes]a *)

FullForm[expression]
(* NonCommutativeMultiply[c,b,a] *)