Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to define a rule that will change a particular type of string to another form. For example:- a string having R1~~"=C"~~"C"("OO|O")~~R2 -> R1~~"C"(O)~~"C"~~R2

share|improve this question
Could you post the complete example (i.e. with original and target string)? Plus, have you looked at the documentation of StringReplace? – Yves Klett Mar 26 '12 at 12:25
What are the specific transformation rules you want to apply? – Brett Champion Mar 26 '12 at 16:04
Welcome to Mathematica.SE, learnmathematica. I hope you will learn a lot here. In order to improve your experience here, you can do a lot yourself. Please try to describe your problem as well as you can and also try to show some effort. Your current question looks a bit like "give me the codez fast!" and I'm sure that's not your intention. You will also notice that comments will trickle in pretty quickly after posting a question. Please, make it a habit to check your question regularly, especially in the beginning, and provide feedback as appropriate. – Sjoerd C. de Vries Mar 26 '12 at 20:22

It is not quite clear what you are aiming to do, but perhaps this would work:

 R1__ ~~ "=C" ~~ x___ ~~ "C(00)" | "C(0)" ~~ R2__ :> 
  R1 <> "C(O)" <> x <> "C" <> R2]


share|improve this answer
You can have a single RuleDelayed instead of two using ...~~"C(00)" | "C(0)"~~... – kglr Mar 26 '12 at 12:46
@ kguler - already put that in, thanks – Chris Degnen Mar 26 '12 at 13:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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