Ok, I give up. I can't figure how to tell Mathematica to do replacement using a pattern except for some special case. Easier to explain with small example.
I want to change pattern
Exp[any_. c] to
c for all cases of pattern
any except when
any happened to be contain the literal symbol
x anywhere in it.
Exp[5 c] will be replaced to
c and so will
Exp[y c] but for
Exp[x c] or
Exp[Sin[x] c] I want no replacement to happen since the term multiplying
x in it.
I am trying to use
Except but can't get it to work. This is what I tried
This does not work
ClearAll[x,c] Exp[ x c] /. Exp[any_. c]:> c
So I need a way to set a pattern which says anything except
x. So tried
Exp[ x c] /. Exp[Alternatives[Except[x], any1_.] c] :> c
It changed it to
c, so pattern matched.
Do I need to use
Verbatim in pattern for this? How?
I reached my limit in pattern matching skills in Mathematica so I need help :)