How to extract a substring when it's length is variable

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<span style="font-size:9pt; color:black; font-family:Verdana Hello,
<span style="font-size:9pt; color:black; font-family:Verdana I am creating a custom style for a Content Query Web PArt in SharePoint 2007. I need to take the FileRef field and extract the document name from it to display on the screen. My URL looks like
this:
<span style="font-size:9pt; color:black; font-family:Verdana /site/subsite/library/MYDOCNAME.pdf
<span style="font-size:9pt; color:black; font-family:Verdana I have managed to get the MYDOCNAME part to disaply with no problem using the following:
<span style="font-size:9pt; color:black; font-family:Verdana <xsl:value-of select="substring(@FileRef,25,10)
<span style="font-size:9pt; color:black; font-family:Verdana This is fine for documents where the name is 10 characters. But the problem is my documents can vary in length from 10 - 12 characters. Also the file extension will not always be 4 characters long
as the new Office file formats are four characters long (making it 5 including the ".")
<span style="font-size:9pt; color:black; font-family:Verdana However my file path will always be 25 characters long this will not change.

<span style="font-size:9pt; color:black; font-family:Verdana Is there some way I can extract a substring that starts after the 25th character and stops when it reaches the "."?


View the full article
 
Back
Top