Approximate String Match Positions
Determine positions of approximate string matches.
aregexec(pattern, text, max.distance = 0.1, costs = NULL, ignore.case = FALSE, fixed = FALSE, useBytes = FALSE)
- a non-empty character string or a character string
containing a regular expression (for
fixed = FALSE) to be matched. Coerced by
as.characterto a string if possible.
- character vector where matches are sought.
as.characterto a character vector if possible.
- maximum distance allowed for a match.
- cost of transformations.
- a logical. If
TRUE, case is ignored for computing the distances.
TRUE, the pattern is matched literally (as is). Otherwise (default), it is matched as a regular expression.
- a logical. If
TRUEcomparisons are byte-by-byte rather than character-by-character.
Note that by default,
agrep performs literal matches,
aregexec performs regular expression matches.
Comparisons are byte-by-byte if
pattern or any element of
text is marked as
A list of the same length as
text, each element of which is either $-1$ if there is no match, or a sequence of integers with the starting positions of the match and all substrings corresponding to parenthesized subexpressions of
pattern, with attribute
"match.length"an integer vector giving the lengths of the matches (or $-1$ for no match).
regmatches for extracting the matched substrings.
## Cf. the examples for agrep. x <- c("1 lazy", "1", "1 LAZY") aregexec("laysy", x, max.distance = 2) aregexec("(lay)(sy)", x, max.distance = 2) aregexec("(lay)(sy)", x, max.distance = 2, ignore.case = TRUE) m <- aregexec("(lay)(sy)", x, max.distance = 2) regmatches(x, m)