File: invert_match.Rd

package info (click to toggle)
r-cran-stringr 0.6.2-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 308 kB
  • sloc: makefile: 3
file content (26 lines) | stat: -rw-r--r-- 641 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
\name{invert_match}
\alias{invert_match}
\title{Switch location of matches to location of non-matches.}
\usage{
  invert_match(loc)
}
\arguments{
  \item{loc}{matrix of match locations, as from
  \code{\link{str_locate_all}}}
}
\value{
  numeric match giving locations of non-matches
}
\description{
  Invert a matrix of match locations to match the opposite
  of what was previously matched.
}
\examples{
numbers <- "1 and 2 and 4 and 456"
num_loc <- str_locate_all(numbers, "[0-9]+")[[1]]
str_sub(numbers, num_loc[, "start"], num_loc[, "end"])

text_loc <- invert_match(num_loc)
str_sub(numbers, text_loc[, "start"], text_loc[, "end"])
}