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!
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityFor 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!
foobar = c ** b ** a;
foobar /. NonCommutativeMultiply[a__] :> Infix[NonCommutativeMultiply[a], "\[InvisibleTimes]"]
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] *)
StringReplace
orStringDelete
and specify appropriate string pattern you want to delete: reference.wolfram.com/language/tutorial/StringPatterns.html $\endgroup$ – Sjoerd Smit Jul 10 '19 at 8:38