Tabular IQ
Back to Function Index

RFIND()

Overview

RFIND() searches for a search string within another string, starting from the right side. It returns the character index of the specified occurrence of the search string. If no occurrence number is specified, it returns the first occurrence from the right. If the search string is not found or the specified occurrence exceeds the available matches, it returns zero.

Function Format

RFIND(string, search string [, occurrence])

Return Value

RFIND() returns an integer

Examples


// Finding first occurrence from right
RFIND("Green apples taste better than red apples and all other types of apples.", "apples") = 66

// No match found
RFIND("Green apples taste better than red apples and all other types of apples.", "oranges") = 0

// Finding specific occurrences from right
RFIND("Green apples taste better than red apples and all other types of apples.", "apples", 1) = 66
RFIND("Green apples taste better than red apples and all other types of apples.", "apples", 2) = 36
RFIND("Green apples taste better than red apples and all other types of apples.", "apples", 3) = 7
RFIND("Green apples taste better than red apples and all other types of apples.", "apples", 4) = 0

Notes

  • Important behaviors:
    • Searches from right to left
    • Returns character index of the match
    • Returns 0 if no match is found
    • Returns 0 if occurrence number exceeds available matches
    • First occurrence (default) is the rightmost match
  • Common use cases include:
    • Finding last occurrences of text
    • Extracting text from the end
    • Pattern matching from right
    • String analysis
    • Data validation
  • The function is useful for:
    • Right-to-left text processing
    • Multiple occurrence tracking
    • String position analysis
    • Pattern detection
  • Considerations:
    • Index is 1-based (first character is position 1)
    • Case sensitive matching
    • Empty search string returns 0
    • Occurrence number must be positive

See Also