Skip to content

RegionMatchers

regionMatch

Compares two strings or regions for equality.

// Matching identical strings
regionMatch('hello', 'hello') // true
// Matching identical regions in strings
const str1 = { str: 'hello world', start: 0, end: 5 }
const str2 = { str: 'hello there', start: 0, end: 5 }
regionMatch(str1, str2) // true
// OR
regionMatch('hello world', 'hello there', 0, 5) // true
// Not matching regions
regionMatch('hello world', 'hello there', 6, 11) // false

looseRegionMatch

Performs a loose comparison of two strings or regions for equality.

// Loose matching identical strings
looseRegionMatch('hello', 'HeLLo') // true
// Loose matching identical regions in strings
const str1 = { str: ' hellO world', start: 1, end: 6 }
const str2 = { str: 'HelLo there', start: 0, end: 5 }
looseRegionMatch(str1, str2) // true