regionMatches.String: Tests if two string regions are equal

Description Usage Arguments Value Author(s) See Also Examples

Description

Tests if two string regions are equal.

Usage

1
2
## S3 method for class 'String'
regionMatches(this, toffset, other, ooffset, len, ignoreCase=FALSE, ...)

Arguments

toffset

The starting offset of the subregion in this string.

other

The other string.

ooffset

The starting offset of the subregion in the other string.

len

The number of characters to compare.

ignoreCase

If TRUE case is ignored.

Value

Returns TRUE if the specified subregion of this string matches the specified subregion of the other string, FALSE otherwise.

Author(s)

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

See Also

*compareTo(), *equals(), *equalsIgnoreCase()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
  s1 <- String("Hello world!")
  s2 <- String("Oh, hello there!")
  regionMatches(s1, 1, s2, 5, 5)        # TRUE
  regionMatches(s2, 5, s1, 1, 5)        # TRUE
  regionMatches(s1, 0, s2, 4, 5)        # FALSE
  regionMatches(s1, 0, s2, 4, 5, TRUE)  # TRUE

  s1 <- "Hello world!"
  s2 <- "Oh, hello there!"
  regionMatches(s1, 1, s2, 5, 5)        # TRUE
  regionMatches(s2, 5, s1, 1, 5)        # TRUE
  regionMatches(s1, 0, s2, 4, 5)        # FALSE
  regionMatches(s1, 0, s2, 4, 5, TRUE)  # TRUE

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