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


  • 1
    $\begingroup$ 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? $\endgroup$
    – Fortsaint
    Jul 10 '19 at 8:38
  • 1
    $\begingroup$ 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 $\endgroup$ Jul 10 '19 at 8:38
  • $\begingroup$ 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 $\endgroup$ Jul 10 '19 at 8:44
  • 1
    $\begingroup$ user66499, i suggest you add the information in your comment to your question. $\endgroup$
    – kglr
    Jul 10 '19 at 9:01
foobar = c ** b ** a;

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

enter image description here

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

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

(* c**b**a *)

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

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

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

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

Mathematica graphics


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.