Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 7th, 2009, 06:34 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Default Get a specific text from a string

With the input "/mvfs/fos-6000/osidcc/src/lapd/Dmain.c", i need the output "/mvfs/fos-6000/osidcc/src/lapd/". Can anyone help on this?
__________________
Rummy
 
Old April 7th, 2009, 06:48 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

XPath 2.0:
Code:
replace('/mvfs/fos-6000/osidcc/src/lapd/Dmain.c', '[^/]+$', '')
This removes any characters from the end of the string that are different from the slash.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog

Last edited by Martin Honnen; April 7th, 2009 at 06:49 AM.. Reason: Corrected typo.
 
Old April 7th, 2009, 06:49 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Probably not the answer you wanted, but:

<xsl:template match="*[.='/mvfs/fos-6000/osidcc/src/lapd/Dmain.c']">
<xsl:copy>/mvfs/fos-6000/osidcc/src/lapd/</xsl:copy>
</xsl:template>

For a more useful answer you will need to tell us more about the possible range of inputs, the output that you want in relation to different inputs, and the place in which these inputs occur.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old April 7th, 2009, 07:03 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Default

Thank you both. Your answer worked.
__________________
Rummy





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to fetch text after specific tag text dipsut XSLT 10 May 23rd, 2007 02:57 PM
Finding specific string martinrhague Access 7 November 2nd, 2006 12:54 PM
getnodes after specific text pendyalap XSLT 1 June 8th, 2006 05:13 PM
How to retrieve specific string zorzos Excel VBA 1 August 25th, 2004 05:41 AM
Finding a specific character within a string tp194 Classic ASP Databases 2 October 12th, 2003 10:41 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.