Name

substring-after()

Given a data string and a search string, returns the portion of the data string after the first occurrence of the search string. If the search string is not found, the substring-after() function returns a zero-length string.

Syntax

[1.0] string substring-after(string, string)
[2.0] xs:string substring-after(xs:string?, xs:string?)
[2.0] xs:string substring-after(xs:string?, xs:string?, 
                                $collation as xs:string)

Inputs

Two strings. The first string is the data string to be searched, and the second is the search string. substring-after() looks for the search string in the data string.

[2.0] In XSLT 2.0, there is an optional third argument: the name of a collation that specifies how strings are compared.

Output

The portion of the data string that occurs after the first occurrence of the search string. If the search string does not appear in the data string, the function returns an empty string. If the second string is a zero-length string, substring-after() returns a zero-length string. The function also returns a zero-length string if the first string is shorter than the second string.

Defined in

[1.0] XPath section 4.2, “String Functions.”

[2.0] XQuery 1.0 and XPath 2.0 Functions and Operators section 7.5, “Functions Based on Substring Matching.”

Example

Here is a sample stylesheet that uses substring-after():

<?xml version="1.0"?>
<!-- substring-after1.xsl --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:template ...

Get XSLT, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.