History | Edit

This function is used to define last occurrence searches.

The oxy_lastindexof() function has two signatures:

  • 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.
  • 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"));
}