# How to set a rule in pattern matching to change a string from one form to another

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

-
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:

StringReplace["r1abc=CxxC(00)r2xyz",
R1__ ~~ "=C" ~~ x___ ~~ "C(00)" | "C(0)" ~~ R2__ :>
R1 <> "C(O)" <> x <> "C" <> R2]


r1abcC(O)xxCr2xyz

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