Finding and replacing content between brackets with jQuery?

You can use the indexOf method: text = $("h2").text(); pos1 = text. IndexOf("("); pos2 = text. IndexOf(")"); newText = text.

Substring(0, pos1 + 1) + myText + text. Substring(pos2) The above assumes that one and only one pair of brackets is to be found in the text.

You can use the indexOf method: text = $("h2").text(); pos1 = text. IndexOf("("); pos2 = text. IndexOf(")"); newText = text.

Substring(0, pos1 + 1) + myText + text. Substring(pos2); The above assumes that one and only one pair of brackets is to be found in the text.

Thanks but this won't work as it will continually prefix the new count before the old count, I need it to replace the content of () with the new count number. I should mention that the state of the string could contain numbers already; at variable length. – user275074 Apr 19 '10 at 13:18 1 See my edited answer.

– kgiannakakis Apr 19 '10 at 13:38 What if the closing bracket is before the opening bracket? – Gumbo Apr 19 '10 at 13:40 Use the following sanity test: if (pos1 > -1 && pos2 > pos1) – kgiannakakis Apr 19 '10 at 14:32.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions