views:

52

answers:

2

Hi, everyone. I've got a string looks like

var s = "2qf/tqg4/ad(d=d,s(f)d)"

And I've got another string

var n = "abc = /fd/dsf/sdf/a.doc, "

What I want to do is insert n after the first '('

So it will look like

"2qf/tqg4/ad(abc = /fd/dsf/sdf/a.doc, d=d,s(f)d)"

Thanks very much!!!

+1  A: 
outis
This answer is more correct at the moment.
Hamish Grubijan
+2  A: 

Just use the replace function:

var result = s.replace("(", "("+n);
casablanca
Would this only changes the first one?
Yes, you can try it yourself.
casablanca
Thank you!!!!!!!
you forgot the first `(` in the replacement string
M42
@M42: Fixed. :)
casablanca