The string-indexof() function
Smartsite 7.2 - ...
The string-indexof() extension function returns the zero-based index of the first occurrence of the specified character or string in this string, or -1 when the character or string is not found in this instance.
| XML |
|
|---|---|
int exf:string-indexof(arg1, string value, int startIndex) |
|
Parameters:
- arg1: a node reference or string literal.
- value: the string to seek.
- startIndex (optional): the search starting position.
Example
| XML |
|
|---|---|
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:exf="http://smartsite.nl/namespaces/xforms/1.0">
<head>
<title>Example</title>
<xf:model>
<xf:instance>
<data xmlns="">
<postcode>2628 XG</postcode>
<text1>Tekst 1</text1>
<indexof>string-indexof(string value, int startIndex)</indexof>
</data>
</xf:instance>
</xf:model>
</head>
<body>
<xf:group ref="/data" appearance="full">
<xf:label />
<xf:output value="exf:string-indexof(postcode, 'X')" />
<xf:output value="exf:string-indexof(postcode, 'x')" />
<xf:output value="exf:string-indexof(indexof, 'i')" />
<xf:output value="exf:string-indexof(indexof, 'i', 10)" />
</xf:group>
</body>
</html>
|
|
The result will be:
5
-1
3
18
Namespace
This function is available within the Smartsite XForms namespace (http://smartsite.nl/namespaces/xforms/1.0).