amayne / SwiftString

A comprehensive, lightweight string extension for Swift
MIT License
1.62k stars 141 forks source link

Add new extension method rindexOf #25

Open enix223 opened 7 years ago

enix223 commented 7 years ago

rindexOf is used to get the last occurrence of the given substring. It is a reverse version of indexOf.

Sample usage as below: rindexOf(substring)

"hello".rindexOf("hell"), // 0
"helloll".rindexOf("ll"), // 5
"hello".rindexOf("world") // nil

Test case for the new method is provided.