I have to create a JS function which guarantees that there can be no text lines with only one word in them. This basically means that I have to replace the space between the last two words in every sentence to a non-breaking one with a simple regular expression.

To ensure that no tags would be altered (e.g. to prevent modifying text in alt or title attributes) the final regular expression should be quite complex.

But if there would be a way to select only the CDATA section of DOM in JavaScript, my task would be much simpler.

Is there a way to find CDATA in DOM with JavaScript? How would you do that?