Re: Question about pattern matching
- To: mathgroup at smc.vnet.net
- Subject: [mg34090] Re: Question about pattern matching
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Thu, 2 May 2002 03:49:34 -0400 (EDT)
- Organization: Universitaet Leipzig
- References: <aaolcf$e8v$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
- Sender: owner-wri-mathgroup at wolfram.com
Hi, and when you try (kg m^2)/(s^2) /. kg m^mu_./(s^2) :> m^(mu - 1)n it returns m*n because Power[m,2] will not match m but Power[m,mu_.] will do that. However it is better to use something like (kg m^2)/(s^2) /. Solve[kg m/(s^2) == n, kg][[1]] Regards Jens Mike Varney wrote: > > Hello. > I have a rather straight forward question on pattern matching. > > Say that I have a expression given as: > > (kg m^2) /(s^2) > > When I try a pattern matching substitution such as: > > (kg m^2) /(s^2) /. (kg m)/(s^2) -> n > > Returns: > (kg m^2) /(s^2) > > Am I missing some sort of rule? How can I do this sort of pattern matching. > > Thanks for you help. > Mike