xquery- how to select text occ. after nth occurrence of delimiter/how to extract first n sentences/last n sentences
===

In a web page, there is a div with the following content--

    <div id="test">
        <p> This is first sentence. This is second sentence. This is third sentence. This is 4th sentence. </p>
    </div>

Now, how do I obtain the text "This is second sentence" from the above HTML fragment? I understand how to get to the div/p within which this text is present, but how to only extract that specific sentence?

Similarly, how do I extract the first 3 sentences? And also, how do I select the last 2 sentences? Finally, your Xquery expression should work for any type of delimiter- like "." / "," / ";" etc...
