rindex() function in Perl operates similar to index() function, except it returns the position of the last occurrence of the substring (or pattern) in the string (or text). If the position is specified, returns the last occurrence at or before that position.
# Searches pat in text from given Position
rindex text, pattern, Position
# Searches pat in text
rindex text, pattern
- text: String in which substring is to be searched.
- pat: Substring to be searched.
- index: Starting index(set by the user or it takes zero by default).
-1 on failure otherwise position of last occurrence.
Position of eks: 19 Position of eks: 11
Position of eek: 10 Position of eek: 2
- Perl | String functions (length, lc, uc, index, rindex)
- Perl | tell() Function
- Perl | cos() Function
- Perl | each() Function
- Perl | abs() function
- Perl | exp Function
- Perl | oct() Function
- Perl | hex Function
- Perl | log() Function
- Perl | chr() Function
- Perl | sin() Function
- Perl | uc() Function
- Perl | ord() Function
- Perl | int() function
- Perl | keys() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : nidhi_biet