What pattern should i give to the following expression

("146d0" A + "-594d0" B)

so i would get

("146d0" A - "594d0" B)
  • 2
    $\begingroup$ Before we get into XY problem solving, what are you trying to achieve? $\endgroup$ – Roman Nov 21 at 20:58
  • 1
    $\begingroup$ What's the point of this question and answer? It makes no sense. $\endgroup$ – user6014 Nov 21 at 21:39
("146d0" A + "-594d0" B) /. s_String?(StringStartsQ["-"]) :> -StringDrop[s, 1]

(*    "146d0" A - "594d0" B    *)

This pattern seems to be working

("146d0" A + "-594d0" B) //. 
   B_] :> -StringDelete[ToString[-ToExpression[A]], " "] B /; 

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.