Examples for 'utils::aregexec'


Approximate String Match Positions

Aliases: aregexec

Keywords: character

### ** Examples

## Cf. the examples for agrep.
x <- c("1 lazy", "1", "1 LAZY")
aregexec("laysy", x, max.distance = 2)
[[1]]
[1] 3
attr(,"match.length")
[1] 4

[[2]]
[1] -1
attr(,"match.length")
[1] -1

[[3]]
[1] -1
attr(,"match.length")
[1] -1
aregexec("(lay)(sy)", x, max.distance = 2)
[[1]]
[1] 3 3 5
attr(,"match.length")
[1] 4 2 2

[[2]]
[1] -1
attr(,"match.length")
[1] -1

[[3]]
[1] -1
attr(,"match.length")
[1] -1
aregexec("(lay)(sy)", x, max.distance = 2, ignore.case = TRUE)
[[1]]
[1] 3 3 6
attr(,"match.length")
[1] 4 3 1

[[2]]
[1] -1
attr(,"match.length")
[1] -1

[[3]]
[1] 3 3 6
attr(,"match.length")
[1] 4 3 1
m <- aregexec("(lay)(sy)", x, max.distance = 2)
regmatches(x, m)
[[1]]
[1] "lazy" "la"   "zy"  

[[2]]
character(0)

[[3]]
character(0)

[Package utils version 4.2.3 Index]