lastIndexOf.String: Gets the last position of a character or a substring

Description Usage Arguments Value Author(s) See Also Examples

Description

Gets the last position of the character or the substring s starting from fromIndex.

Usage

1
2
## S3 method for class 'String'
lastIndexOf(this, s, fromIndex=0, ...)

Arguments

fromIndex

The index to start the search from.

Value

Returns the position. If no such character exists, -1 is returned.

Author(s)

Henrik Bengtsson (http://www.braju.com/R/)

See Also

*indexOf(), *charAt()

Examples

1
2
3
4
5
  s <- String("Hello world!")
  lastIndexOf(s, " ")               # 5
  lastIndexOf(s, "l")               # 9
  lastIndexOf(s, "l", fromIndex=5)  # 3
  lastIndexOf("Hello world!", " ")  # 5

HenrikBengtsson/R.lang documentation built on May 8, 2019, 7:50 p.m.