Name
fn:substring
Synopsis
This function extracts the part of a string between two indexes and returns it. If the “begin” index is less than 0 it’s treated as 0, and if it’s greater than the length of the string, an empty string is returned. If the “end” index is less than 0 or greater than the length of the string, it’s treated as if it had the length of the string as its value. If the “end” index is less than the “begin” index, an empty string is returned.
Syntax
String: fn:substring(string
,begin
,
end
)
Parameters
Parameter name |
Java type |
Description |
string |
String |
The string to extract from. |
begin |
int |
The index of the first character to include, inclusive. |
end |
Int |
The index of the last character to include, exclusive. |
Example
You can't spell Evil without ${fn:substring('Evil', 1, 3)}
Get JavaServer Pages, 3rd 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.