XSLT – count whitespace using regular expression

I have a xml like follows,

    <p>  first sentence</p>
    <p>second sentence</p>
    <p>          third sentence</p>

I need to count the number of spaces (white space) before start the text in <p> nodes.
So in above example 2,0,10 should be return.

I can use count() function to get the count and separate the white space string using tokenize() but my problem is write a regular expression to get the needed white space. How can I write a regular expression to get those white spaces?

Source: xml

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.