I have a string like this:
Heading
Some interesting text here
HeadingSome interesting text hereHeading
Some interesting text here
Heading
Some interesting text here
What I want to do, is to add another heading under the third heading so it would end up looking like this:
Heading
Some interesting text here
HeadingSome interesting text hereHeadingHeading
Some interesting text here
Heading
Some interesting text here
I'm looking for a generalized method to select any heading and append stuff to it.
Here's a second and third example:
I have a string. Let's not use any DOM terms because they cause confusion.
My name is Mark. My name is Mark. My name is Mark. My name is Mark.
I want to add the string 'and my car is red" to the third repeat of 'My name is Mark.'
My name is Mark. My name is Mark. My name is Mark and my car is red. My name is Mark.
Here's another example:
My car is red. My car is red. My car is red. My car is red.
On the fourth repeat I want to change the text to 'My car is blue.'
My car is red. My car is red. My car is red. My car is blue.
Thanks!
I asked a potentially related question that I wasn't able to find an answer for. But everyone there says it's easy to do with regex: http://stackoverflow.com/questions/1146027/javascript-string-library
Edit: Added regex to tags.
I am so confused. Apparently people have take some issue with the question. If you think the question is missing some information, please ask, I'll do my best to create a sensible question.
Edit: Added more examples.
Thanks!