Last Occurrence: oxy_lastindexof() Function
This function is used to define last occurrence searches.
The oxy_lastindexof()
function has two signatures:
- Syntax 1:
-
oxy_lastindexof ( text , toFind )
Returns the index within text string of the rightmost occurrence of the toFind substring.
- text
- Text to search in.
- toFind
- The searched substring.
- Syntax 2:
-
oxy_lastindexof ( text , toFind , fromOffset )
The search starts from fromOffset index. Returns the index within text string of the last occurrence of the toFind substring, searching backwards starting from the fromOffset index.
- text
- Text to search in.
- toFind
- The searched substring.
- fromOffset
- The index to start the search backwards from.
Example: oxy_lastindexof Function
oxy_lastindexof('abcdbc', 'bc')
returns 4.
oxy_lastindexof('abcdbccdbc', 'bc', 2)
returns 1.
If you only want to display part of an attribute value, for instance the
part that comes before an Appendix
string:
image[longdesc]{
content: oxy_substring(attr(longdesc), 0,
oxy_lastindexof(attr(longdesc), "Appendix"));
}