Insert a String in Gui.TextField text?

Hi , say i have a TextField string that sais:

"a= Mathf.Cos(a)+b;"

And a Gui button called “sin”

If i select Mathf.Cos and press gui button sin, i want it to insert the string: “Mathf.Sin” on the area that is selected/ highlighted by mouse in TextField, so the string becomes:

"a= Mathf.Sin(a)+b;"

whats the best method for it?