From 62c1bef943f0b1aa470ebd019aa93cc9fd8e1f76 Mon Sep 17 00:00:00 2001 From: qinwf Date: Mon, 11 Jul 2016 09:21:29 +0800 Subject: [PATCH] Update: Rd documents --- NAMESPACE | 72 +++++++------- man/UNANCHORED.Rd | 66 ++++++------- man/get_expression_size.Rd | 48 +++++----- man/get_named_groups.Rd | 54 +++++------ man/get_number_of_groups.Rd | 58 +++++------ man/get_options.Rd | 21 ++++ man/get_pattern.Rd | 48 +++++----- man/get_program_fanout.Rd | 52 +++++----- man/get_simplify.Rd | 52 +++++----- man/is_re2c_na.Rd | 21 ++++ man/print.re2c.Rd | 42 ++++---- man/quote_meta.Rd | 56 +++++------ man/re2.Rd | 186 ++++++++++++++++++------------------ man/re2_detect.Rd | 80 ++++++++-------- man/re2_extract.Rd | 60 ++++++------ man/re2_locate.Rd | 58 +++++------ man/re2_match.Rd | 106 ++++++++++---------- man/re2_replace.Rd | 84 ++++++++-------- man/re2_split.Rd | 66 ++++++------- man/re2_subset.Rd | 84 ++++++++-------- man/show_regex.Rd | 104 ++++++++++---------- man/sub_string.Rd | 80 ++++++++-------- re2r.Rproj | 46 ++++----- 23 files changed, 794 insertions(+), 750 deletions(-) create mode 100644 man/get_options.Rd create mode 100644 man/is_re2c_na.Rd diff --git a/NAMESPACE b/NAMESPACE index c792dc7..e4e332a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,35 +1,37 @@ -# Generated by roxygen2: do not edit by hand - -S3method(print,re2c) -export("re2_subset<-") -export("sub_string<-") -export(ANCHOR_BOTH) -export(ANCHOR_START) -export(UNANCHORED) -export(get_expression_size) -export(get_named_groups) -export(get_number_of_groups) -export(get_pattern) -export(get_program_fanout) -export(get_simplify) -export(quote_meta) -export(re2) -export(re2_detect) -export(re2_extract) -export(re2_extract_all) -export(re2_locate) -export(re2_locate_all) -export(re2_match) -export(re2_match_all) -export(re2_replace) -export(re2_replace_all) -export(re2_split) -export(re2_split_fixed) -export(re2_subset) -export(show_regex) -export(sub_string) -import(Rcpp) -import(htmlwidgets) -importFrom(RcppParallel,RcppParallelLibs) -importFrom(stringi,stri_enc_toutf8) -useDynLib(re2r) +# Generated by roxygen2: do not edit by hand + +S3method(print,re2c) +export("re2_subset<-") +export("sub_string<-") +export(ANCHOR_BOTH) +export(ANCHOR_START) +export(UNANCHORED) +export(get_expression_size) +export(get_named_groups) +export(get_number_of_groups) +export(get_options) +export(get_pattern) +export(get_program_fanout) +export(get_simplify) +export(is_re2c_na) +export(quote_meta) +export(re2) +export(re2_detect) +export(re2_extract) +export(re2_extract_all) +export(re2_locate) +export(re2_locate_all) +export(re2_match) +export(re2_match_all) +export(re2_replace) +export(re2_replace_all) +export(re2_split) +export(re2_split_fixed) +export(re2_subset) +export(show_regex) +export(sub_string) +import(Rcpp) +import(htmlwidgets) +importFrom(RcppParallel,RcppParallelLibs) +importFrom(stringi,stri_enc_toutf8) +useDynLib(re2r) diff --git a/man/UNANCHORED.Rd b/man/UNANCHORED.Rd index 9762daa..c5fb741 100644 --- a/man/UNANCHORED.Rd +++ b/man/UNANCHORED.Rd @@ -1,33 +1,33 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/anchor.R -\docType{data} -\name{UNANCHORED} -\alias{ANCHOR_BOTH} -\alias{ANCHOR_START} -\alias{UNANCHORED} -\title{Anchors for pattern} -\format{An object of class \code{numeric} of length 1.} -\usage{ -UNANCHORED - -ANCHOR_START - -ANCHOR_BOTH -} -\description{ -Anchors for regular expression pattern string. -} -\details{ -UNANCHORED - No anchoring - -ANCHOR_START - Anchor at start only - -ANCHOR_BOTH - Anchor at start and end -} -\examples{ -re2_match("This is an apple.", "(is)",anchor = ANCHOR_BOTH) -re2_match("This is an apple.", "(This)",anchor = ANCHOR_START) -re2_match("This is an apple.", "(is)",anchor = UNANCHORED) -} -\keyword{datasets} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/anchor.R +\docType{data} +\name{UNANCHORED} +\alias{ANCHOR_BOTH} +\alias{ANCHOR_START} +\alias{UNANCHORED} +\title{Anchors for pattern} +\format{An object of class \code{numeric} of length 1.} +\usage{ +UNANCHORED + +ANCHOR_START + +ANCHOR_BOTH +} +\description{ +Anchors for regular expression pattern string. +} +\details{ +UNANCHORED - No anchoring + +ANCHOR_START - Anchor at start only + +ANCHOR_BOTH - Anchor at start and end +} +\examples{ +re2_match("This is an apple.", "(is)",anchor = ANCHOR_BOTH) +re2_match("This is an apple.", "(This)",anchor = ANCHOR_START) +re2_match("This is an apple.", "(is)",anchor = UNANCHORED) +} +\keyword{datasets} + diff --git a/man/get_expression_size.Rd b/man/get_expression_size.Rd index 7b57875..4c5cd9e 100644 --- a/man/get_expression_size.Rd +++ b/man/get_expression_size.Rd @@ -1,24 +1,24 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{get_expression_size} -\alias{get_expression_size} -\title{Get pre-compiled regular expression program size} -\usage{ -get_expression_size(regexp) -} -\arguments{ -\item{regexp}{a pre-compiled regular expression} -} -\value{ -a integer -} -\description{ -Returns the program size, a very approximate measure of a regexp's "cost". -Larger numbers are more expensive than smaller numbers. -} -\examples{ -get_expression_size(re2("1")) -get_expression_size(re2("(1)")) -get_expression_size(re2("(?:(?:(?:(?:(?:.)?){100})*)+)")) -} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/RcppExports.R +\name{get_expression_size} +\alias{get_expression_size} +\title{Get pre-compiled regular expression program size} +\usage{ +get_expression_size(regexp) +} +\arguments{ +\item{regexp}{a pre-compiled regular expression} +} +\value{ +a integer +} +\description{ +Returns the program size, a very approximate measure of a regexp's "cost". +Larger numbers are more expensive than smaller numbers. +} +\examples{ +get_expression_size(re2("1")) +get_expression_size(re2("(1)")) +get_expression_size(re2("(?:(?:(?:(?:(?:.)?){100})*)+)")) +} + diff --git a/man/get_named_groups.Rd b/man/get_named_groups.Rd index 7ffb24d..ff397a4 100644 --- a/man/get_named_groups.Rd +++ b/man/get_named_groups.Rd @@ -1,27 +1,27 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/compile.R -\name{get_named_groups} -\alias{get_named_groups} -\title{Return capturing names for a pre-compiled regular expression.} -\usage{ -get_named_groups(regexp) -} -\arguments{ -\item{regexp}{a pre-compiled regular expression} -} -\value{ -capturing names -} -\description{ -Return capturing names. -} -\examples{ -get_named_groups(re2("(a)(?Pb)")) - -regexp = re2("(?PexprA(?PexprB)(?PexprC))((expr5)(?PexprD))") - -print(regexp) -(res = get_named_groups(regexp)) -re2_match("exprAexprBexprCexpr5exprD", regexp) -} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/compile.R +\name{get_named_groups} +\alias{get_named_groups} +\title{Return capturing names for a pre-compiled regular expression.} +\usage{ +get_named_groups(regexp) +} +\arguments{ +\item{regexp}{a pre-compiled regular expression} +} +\value{ +capturing names +} +\description{ +Return capturing names. +} +\examples{ +get_named_groups(re2("(a)(?Pb)")) + +regexp = re2("(?PexprA(?PexprB)(?PexprC))((expr5)(?PexprD))") + +print(regexp) +(res = get_named_groups(regexp)) +re2_match("exprAexprBexprCexpr5exprD", regexp) +} + diff --git a/man/get_number_of_groups.Rd b/man/get_number_of_groups.Rd index c830ddf..b2744bf 100644 --- a/man/get_number_of_groups.Rd +++ b/man/get_number_of_groups.Rd @@ -1,29 +1,29 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{get_number_of_groups} -\alias{get_number_of_groups} -\title{Return the number of capturing subpatterns} -\usage{ -get_number_of_groups(regexp) -} -\arguments{ -\item{regexp}{a pre-compiled regular expression} -} -\value{ -a integer -} -\description{ -Return the number of capturing subpatterns, or -1 if the -regexp wasn't valid on construction. The overall match ($0) -does not count: if the regexp is "(a)(b)", returns 2. -} -\examples{ -regexp = re2("1") -get_number_of_groups(regexp) - -get_number_of_groups(re2("((?P123)(12))")) - -# uncaptured groups -get_number_of_groups(re2("(?:(?:(?:(?:(?:.)?){100})*)+)")) -} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/RcppExports.R +\name{get_number_of_groups} +\alias{get_number_of_groups} +\title{Return the number of capturing subpatterns} +\usage{ +get_number_of_groups(regexp) +} +\arguments{ +\item{regexp}{a pre-compiled regular expression} +} +\value{ +a integer +} +\description{ +Return the number of capturing subpatterns, or -1 if the +regexp wasn't valid on construction. The overall match ($0) +does not count: if the regexp is "(a)(b)", returns 2. +} +\examples{ +regexp = re2("1") +get_number_of_groups(regexp) + +get_number_of_groups(re2("((?P123)(12))")) + +# uncaptured groups +get_number_of_groups(re2("(?:(?:(?:(?:(?:.)?){100})*)+)")) +} + diff --git a/man/get_options.Rd b/man/get_options.Rd new file mode 100644 index 0000000..3e03440 --- /dev/null +++ b/man/get_options.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/RcppExports.R +\name{get_options} +\alias{get_options} +\title{Get options of a pre-compiled regular expression} +\usage{ +get_options(regexp) +} +\arguments{ +\item{regexp}{a pre-compiled regular expression} +} +\value{ +an R list +} +\description{ +Returns options of a pre-compiled regular expression +} +\examples{ +get_options(re2("test")) +} + diff --git a/man/get_pattern.Rd b/man/get_pattern.Rd index 5eda9f6..b46b15c 100644 --- a/man/get_pattern.Rd +++ b/man/get_pattern.Rd @@ -1,24 +1,24 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/compile.R -\name{get_pattern} -\alias{get_pattern} -\title{The string specification for this RE2.} -\usage{ -get_pattern(regexp) -} -\arguments{ -\item{regexp}{a pre-compiled regular expression} -} -\value{ -a string -} -\description{ -The string specification for this RE2. -} -\examples{ -regexp = re2("1") -get_pattern(regexp) - -get_pattern(re2("^(?Pabc)a")) -} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/compile.R +\name{get_pattern} +\alias{get_pattern} +\title{The string specification for this RE2.} +\usage{ +get_pattern(regexp) +} +\arguments{ +\item{regexp}{a pre-compiled regular expression} +} +\value{ +a string +} +\description{ +The string specification for this RE2. +} +\examples{ +regexp = re2("1") +get_pattern(regexp) + +get_pattern(re2("^(?Pabc)a")) +} + diff --git a/man/get_program_fanout.Rd b/man/get_program_fanout.Rd index b9e5cbf..e6cc426 100644 --- a/man/get_program_fanout.Rd +++ b/man/get_program_fanout.Rd @@ -1,26 +1,26 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/fanout.R -\name{get_program_fanout} -\alias{get_program_fanout} -\title{Get program fanout} -\usage{ -get_program_fanout(regexp) -} -\arguments{ -\item{regexp}{a pre-compiled regular expression} -} -\description{ -Return the program fanout as a histogram bucketed by powers of 2. -} -\examples{ -re1 = re2("(?:(?:(?:(?:(?:.)?){1})*)+)") -re10 = re2("(?:(?:(?:(?:(?:.)?){10})*)+)") -re100 = re2("(?:(?:(?:(?:(?:.)?){100})*)+)") -re1000 = re2("(?:(?:(?:(?:(?:.)?){1000})*)+)") - -get_program_fanout(re1) -get_program_fanout(re10) -get_program_fanout(re100) -get_program_fanout(re1000) -} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fanout.R +\name{get_program_fanout} +\alias{get_program_fanout} +\title{Get program fanout} +\usage{ +get_program_fanout(regexp) +} +\arguments{ +\item{regexp}{a pre-compiled regular expression} +} +\description{ +Return the program fanout as a histogram bucketed by powers of 2. +} +\examples{ +re1 = re2("(?:(?:(?:(?:(?:.)?){1})*)+)") +re10 = re2("(?:(?:(?:(?:(?:.)?){10})*)+)") +re100 = re2("(?:(?:(?:(?:(?:.)?){100})*)+)") +re1000 = re2("(?:(?:(?:(?:(?:.)?){1000})*)+)") + +get_program_fanout(re1) +get_program_fanout(re10) +get_program_fanout(re100) +get_program_fanout(re1000) +} + diff --git a/man/get_simplify.Rd b/man/get_simplify.Rd index 99c6136..16097f9 100644 --- a/man/get_simplify.Rd +++ b/man/get_simplify.Rd @@ -1,26 +1,26 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/simplify.R -\name{get_simplify} -\alias{get_simplify} -\title{Simplify pattern strings.} -\usage{ -get_simplify(pattern, ...) -} -\arguments{ -\item{pattern}{a pre-compiled regular expression or a string} - -\item{...}{further arguments to compile input character.} - -\item{input}{a character vector} -} -\description{ -Simplify pattern strings. -} -\examples{ -get_simplify("a{1}") -get_simplify("a{3}b+(:?abc(a))") -get_simplify("a{2,3}a{2}") -get_simplify(re2("1+2",literal = TRUE)) -get_pattern(re2("1+2",literal = TRUE)) -} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/simplify.R +\name{get_simplify} +\alias{get_simplify} +\title{Simplify pattern strings.} +\usage{ +get_simplify(pattern, ...) +} +\arguments{ +\item{pattern}{a pre-compiled regular expression or a string} + +\item{...}{further arguments to compile input character.} + +\item{input}{a character vector} +} +\description{ +Simplify pattern strings. +} +\examples{ +get_simplify("a{1}") +get_simplify("a{3}b+(:?abc(a))") +get_simplify("a{2,3}a{2}") +get_simplify(re2("1+2",literal = TRUE)) +get_pattern(re2("1+2",literal = TRUE)) +} + diff --git a/man/is_re2c_na.Rd b/man/is_re2c_na.Rd new file mode 100644 index 0000000..1634073 --- /dev/null +++ b/man/is_re2c_na.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/RcppExports.R +\name{is_re2c_na} +\alias{is_re2c_na} +\title{Check NA pattern} +\usage{ +is_re2c_na(regexp) +} +\arguments{ +\item{regexp}{a pre-compiled regular expression} +} +\value{ +boolean +} +\description{ +Returns whether a pre-compiled regular expression is NA. +} +\examples{ +is_re2c_na(re2(NA)) +} + diff --git a/man/print.re2c.Rd b/man/print.re2c.Rd index e685dd3..5ee8aa4 100644 --- a/man/print.re2c.Rd +++ b/man/print.re2c.Rd @@ -1,21 +1,21 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/print.R -\name{print.re2c} -\alias{print.re2c} -\title{Print information about a pre-compiled regular expression} -\usage{ -\method{print}{re2c}(x, ...) -} -\arguments{ -\item{x}{a pre-compiled regular expression} - -\item{...}{further arguments passed to or from other methods.} -} -\description{ -Print information about a pre-compiled regular expression -} -\examples{ -re2("(.*)@([^.]*)") -re2("(?Psd)") -} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/print.R +\name{print.re2c} +\alias{print.re2c} +\title{Print information about a pre-compiled regular expression} +\usage{ +\method{print}{re2c}(x, ...) +} +\arguments{ +\item{x}{a pre-compiled regular expression} + +\item{...}{further arguments passed to or from other methods.} +} +\description{ +Print information about a pre-compiled regular expression +} +\examples{ +re2("(.*)@([^.]*)") +re2("(?Psd)") +} + diff --git a/man/quote_meta.Rd b/man/quote_meta.Rd index 506510a..02358e9 100644 --- a/man/quote_meta.Rd +++ b/man/quote_meta.Rd @@ -1,28 +1,28 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/compile.R -\name{quote_meta} -\alias{quote_meta} -\title{Escapes all potentially meaningful regexp characters in 'unquoted'.} -\usage{ -quote_meta(unquoted, parallel = FALSE, grain_size = 1e+05) -} -\arguments{ -\item{unquoted}{unquoted string} - -\item{parallel}{multithreading support} - -\item{grain_size}{a minimum chunk size for tuning the behavior of parallel algorithms.} -} -\value{ -quoted string -} -\description{ -The returned string, used as a regular expression, will exactly match the original string. -} -\examples{ -quote_meta(c("1.2","abc")) -re2_detect("1+2", "1+2") -re2_detect("1+2", quote_meta("1+2")) -re2_detect("1+2", re2("1+2",literal = TRUE)) -} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/compile.R +\name{quote_meta} +\alias{quote_meta} +\title{Escapes all potentially meaningful regexp characters in 'unquoted'.} +\usage{ +quote_meta(unquoted, parallel = FALSE, grain_size = 1e+05) +} +\arguments{ +\item{unquoted}{unquoted string} + +\item{parallel}{multithreading support} + +\item{grain_size}{a minimum chunk size for tuning the behavior of parallel algorithms.} +} +\value{ +quoted string +} +\description{ +The returned string, used as a regular expression, will exactly match the original string. +} +\examples{ +quote_meta(c("1.2","abc")) +re2_detect("1+2", "1+2") +re2_detect("1+2", quote_meta("1+2")) +re2_detect("1+2", re2("1+2",literal = TRUE)) +} + diff --git a/man/re2.Rd b/man/re2.Rd index d21b792..c6b4c04 100644 --- a/man/re2.Rd +++ b/man/re2.Rd @@ -1,93 +1,93 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/compile.R -\name{re2} -\alias{re2} -\title{Create a pre-compiled regular expression} -\usage{ -re2(pattern, utf_8 = TRUE, case_sensitive = TRUE, posix_syntax = FALSE, - dot_nl = FALSE, literal = FALSE, longest_match = FALSE, - never_nl = FALSE, never_capture = FALSE, one_line = FALSE, - perl_classes = FALSE, word_boundary = FALSE, log_error = FALSE, - max_mem = 8388608, simplify = TRUE) -} -\arguments{ -\item{pattern}{regular expression pattern} - -\item{utf_8}{(true) text and pattern are UTF-8; otherwise Latin-1} - -\item{case_sensitive}{(true) match is case-sensitive (regexp can override with (?i) unless in posix_syntax mode)} - -\item{posix_syntax}{(false) restrict regexps to POSIX egrep syntax} - -\item{dot_nl}{(false) dot matches everything including new line} - -\item{literal}{(false) interpret string as literal, not regexp} - -\item{longest_match}{(false) search for longest match, not first match} - -\item{never_nl}{(false) never match \\n, even if it is in regexp} - -\item{never_capture}{(false) parse all parens as non-capturing} - -\item{one_line}{(false) ^ and $ only match beginning and end of text, when posix_syntax == false this features are always enabled} - -\item{perl_classes}{(false) allow Perl's \\d \\s \\w \\D \\S \\W, when posix_syntax == false this features are always enabled} - -\item{word_boundary}{(false) allow Perl's \\b \\B (word boundary and not), when posix_syntax == false this features are always enabled} - -\item{log_error}{(false) log syntax and execution errors} - -\item{max_mem}{(see details) approx. max memory footprint of RE2} - -\item{simplify}{(true) return a object instead of a list when pattern length is 1.} -} -\value{ -a pre-compiled regular expression -} -\description{ -Create a pre-compiled regular expression from a string. -} -\details{ -The max_mem option controls how much memory can be used -to hold the compiled form of the regexp (the Prog) and -its cached DFA graphs. Code Search placed limits on the number -of Prog instructions and DFA states: 10,000 for both. -In RE2, those limits would translate to about 240 KB per Prog -and perhaps 2.5 MB per DFA (DFA state sizes vary by regexp; - -RE2 does a better job of keeping them small than Code Search did). -Each RE2 has two Progs (one forward, one reverse), and each Prog -can have two DFAs (one first match, one longest match). -That makes 4 DFAs: - - forward, first-match - used for UNANCHORED or ANCHOR_LEFT searches -if opt.longest_match() == false - -forward, longest-match - used for all ANCHOR_BOTH searches, -and the other two kinds if -opt.longest_match() == true - -reverse, first-match - never used - -reverse, longest-match - used as second phase for unanchored searches - -The RE2 memory budget is statically divided between the two -Progs and then the DFAs: two thirds to the forward Prog -and one third to the reverse Prog. The forward Prog gives half -of what it has left over to each of its DFAs. The reverse Prog -gives it all to its longest-match DFA. - -Once a DFA fills its budget, it flushes its cache and starts over. -If this happens too often, RE2 falls back on the NFA implementation. - -For now, make the default budget something close to Code Search. - -DefaultMaxMem = 8<<20; -} -\examples{ -regexp = re2("test") -regexp -regexp \%<~\% "(?P1*)" -regexp -} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/compile.R +\name{re2} +\alias{re2} +\title{Create a pre-compiled regular expression} +\usage{ +re2(pattern, utf_8 = TRUE, case_sensitive = TRUE, posix_syntax = FALSE, + dot_nl = FALSE, literal = FALSE, longest_match = FALSE, + never_nl = FALSE, never_capture = FALSE, one_line = FALSE, + perl_classes = FALSE, word_boundary = FALSE, log_error = FALSE, + max_mem = 8388608, simplify = TRUE) +} +\arguments{ +\item{pattern}{regular expression pattern} + +\item{utf_8}{(true) text and pattern are UTF-8; otherwise Latin-1} + +\item{case_sensitive}{(true) match is case-sensitive (regexp can override with (?i) unless in posix_syntax mode)} + +\item{posix_syntax}{(false) restrict regexps to POSIX egrep syntax} + +\item{dot_nl}{(false) dot matches everything including new line} + +\item{literal}{(false) interpret string as literal, not regexp} + +\item{longest_match}{(false) search for longest match, not first match} + +\item{never_nl}{(false) never match \\n, even if it is in regexp} + +\item{never_capture}{(false) parse all parens as non-capturing} + +\item{one_line}{(false) ^ and $ only match beginning and end of text, when posix_syntax == false this features are always enabled} + +\item{perl_classes}{(false) allow Perl's \\d \\s \\w \\D \\S \\W, when posix_syntax == false this features are always enabled} + +\item{word_boundary}{(false) allow Perl's \\b \\B (word boundary and not), when posix_syntax == false this features are always enabled} + +\item{log_error}{(false) log syntax and execution errors} + +\item{max_mem}{(see details) approx. max memory footprint of RE2} + +\item{simplify}{(true) return a object instead of a list when pattern length is 1.} +} +\value{ +a pre-compiled regular expression +} +\description{ +Create a pre-compiled regular expression from a string. +} +\details{ +The max_mem option controls how much memory can be used +to hold the compiled form of the regexp (the Prog) and +its cached DFA graphs. Code Search placed limits on the number +of Prog instructions and DFA states: 10,000 for both. +In RE2, those limits would translate to about 240 KB per Prog +and perhaps 2.5 MB per DFA (DFA state sizes vary by regexp; + +RE2 does a better job of keeping them small than Code Search did). +Each RE2 has two Progs (one forward, one reverse), and each Prog +can have two DFAs (one first match, one longest match). +That makes 4 DFAs: + + forward, first-match - used for UNANCHORED or ANCHOR_LEFT searches +if opt.longest_match() == false + +forward, longest-match - used for all ANCHOR_BOTH searches, +and the other two kinds if +opt.longest_match() == true + +reverse, first-match - never used + +reverse, longest-match - used as second phase for unanchored searches + +The RE2 memory budget is statically divided between the two +Progs and then the DFAs: two thirds to the forward Prog +and one third to the reverse Prog. The forward Prog gives half +of what it has left over to each of its DFAs. The reverse Prog +gives it all to its longest-match DFA. + +Once a DFA fills its budget, it flushes its cache and starts over. +If this happens too often, RE2 falls back on the NFA implementation. + +For now, make the default budget something close to Code Search. + +DefaultMaxMem = 8<<20; +} +\examples{ +regexp = re2("test") +regexp +regexp \%<~\% "(?P1*)" +regexp +} + diff --git a/man/re2_detect.Rd b/man/re2_detect.Rd index 1864b0e..60e1560 100644 --- a/man/re2_detect.Rd +++ b/man/re2_detect.Rd @@ -1,40 +1,40 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/detect.R -\name{re2_detect} -\alias{re2_detect} -\title{Test a pattern in strings, and return boolean.} -\usage{ -re2_detect(string, pattern, anchor = UNANCHORED, parallel = FALSE, - grain_size = 1e+05, ...) -} -\arguments{ -\item{string}{a character vector} - -\item{pattern}{a pre-compiled regular expression or a string} - -\item{anchor}{UNANCHORED: no anchor. ANCHOR_START: anchor match at the beginning of the string. ANCHOR_BOTH: anchor match at the beginning and the end of the string.} - -\item{parallel}{use multithread} - -\item{grain_size}{a minimum chunk size for tuning the behavior of parallel algorithms} - -\item{...}{further arguments passed to or from other methods.} -} -\description{ -Test a pattern in strings, and return boolean. -} -\examples{ -re2_detect("one", "(o.e)") -re2_detect("123-234-2222", "\\\\d\\\\d\\\\d-\\\\d\\\\d\\\\d-\\\\d\\\\d\\\\d\\\\d") - -words = c("sunny","beach","happy","really") -re2_detect(words, "y") -re2_detect(words, "^b") -re2_detect(words, "[abc]") - -# vectorize -(res = re2_detect("This", letters)) -letters[res] - -} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/detect.R +\name{re2_detect} +\alias{re2_detect} +\title{Test a pattern in strings, and return boolean.} +\usage{ +re2_detect(string, pattern, anchor = UNANCHORED, parallel = FALSE, + grain_size = 1e+05, ...) +} +\arguments{ +\item{string}{a character vector} + +\item{pattern}{a pre-compiled regular expression or a string} + +\item{anchor}{UNANCHORED: no anchor. ANCHOR_START: anchor match at the beginning of the string. ANCHOR_BOTH: anchor match at the beginning and the end of the string.} + +\item{parallel}{use multithread} + +\item{grain_size}{a minimum chunk size for tuning the behavior of parallel algorithms} + +\item{...}{further arguments passed to or from other methods.} +} +\description{ +Test a pattern in strings, and return boolean. +} +\examples{ +re2_detect("one", "(o.e)") +re2_detect("123-234-2222", "\\\\d\\\\d\\\\d-\\\\d\\\\d\\\\d-\\\\d\\\\d\\\\d\\\\d") + +words = c("sunny","beach","happy","really") +re2_detect(words, "y") +re2_detect(words, "^b") +re2_detect(words, "[abc]") + +# vectorize +(res = re2_detect("This", letters)) +letters[res] + +} + diff --git a/man/re2_extract.Rd b/man/re2_extract.Rd index b94509e..26f27e3 100644 --- a/man/re2_extract.Rd +++ b/man/re2_extract.Rd @@ -1,30 +1,30 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/extract.R -\name{re2_extract} -\alias{re2_extract} -\alias{re2_extract_all} -\title{Extract a pattern in strings.} -\usage{ -re2_extract(input, pattern, parallel = FALSE, grain_size = 1e+05, ...) - -re2_extract_all(input, pattern, parallel = FALSE, grain_size = 1e+05, ...) -} -\arguments{ -\item{input}{a character vector} - -\item{pattern}{a pre-compiled regular expression or a string} - -\item{parallel}{use multithread} - -\item{grain_size}{a minimum chunk size for tuning the behavior of parallel algorithms} - -\item{...}{further arguments passed to or from other methods.} -} -\description{ -Like re2_replace, except that if the pattern matches, substring is copied into the result. The non-matching -portions of "text" are ignored. -} -\examples{ -re2_extract("yabba dabba doo", "(.)") -} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/extract.R +\name{re2_extract} +\alias{re2_extract} +\alias{re2_extract_all} +\title{Extract a pattern in strings.} +\usage{ +re2_extract(input, pattern, parallel = FALSE, grain_size = 1e+05, ...) + +re2_extract_all(input, pattern, parallel = FALSE, grain_size = 1e+05, ...) +} +\arguments{ +\item{input}{a character vector} + +\item{pattern}{a pre-compiled regular expression or a string} + +\item{parallel}{use multithread} + +\item{grain_size}{a minimum chunk size for tuning the behavior of parallel algorithms} + +\item{...}{further arguments passed to or from other methods.} +} +\description{ +Like re2_replace, except that if the pattern matches, substring is copied into the result. The non-matching +portions of "text" are ignored. +} +\examples{ +re2_extract("yabba dabba doo", "(.)") +} + diff --git a/man/re2_locate.Rd b/man/re2_locate.Rd index 58375ef..c6c8c3b 100644 --- a/man/re2_locate.Rd +++ b/man/re2_locate.Rd @@ -1,29 +1,29 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/locate.R -\name{re2_locate} -\alias{re2_locate} -\alias{re2_locate_all} -\title{Locate a pattern in strings.} -\usage{ -re2_locate(string, pattern, parallel = FALSE, grain_size = 1e+05, ...) - -re2_locate_all(string, pattern, parallel = FALSE, grain_size = 1e+05, ...) -} -\arguments{ -\item{string}{a character vector} - -\item{pattern}{a pre-compiled regular expression or a string} - -\item{parallel}{use multithread} - -\item{grain_size}{a minimum chunk size for tuning the behavior of parallel algorithms} - -\item{...}{further arguments passed to or from other methods.} -} -\description{ -If the match is of length 0, (e.g. from a special match like $) end will be one character less than start. -} -\examples{ -re2_locate("yabba dabba doo", "d") -} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/locate.R +\name{re2_locate} +\alias{re2_locate} +\alias{re2_locate_all} +\title{Locate a pattern in strings.} +\usage{ +re2_locate(string, pattern, parallel = FALSE, grain_size = 1e+05, ...) + +re2_locate_all(string, pattern, parallel = FALSE, grain_size = 1e+05, ...) +} +\arguments{ +\item{string}{a character vector} + +\item{pattern}{a pre-compiled regular expression or a string} + +\item{parallel}{use multithread} + +\item{grain_size}{a minimum chunk size for tuning the behavior of parallel algorithms} + +\item{...}{further arguments passed to or from other methods.} +} +\description{ +If the match is of length 0, (e.g. from a special match like $) end will be one character less than start. +} +\examples{ +re2_locate("yabba dabba doo", "d") +} + diff --git a/man/re2_match.Rd b/man/re2_match.Rd index b0fecda..0fc87f4 100644 --- a/man/re2_match.Rd +++ b/man/re2_match.Rd @@ -1,53 +1,53 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/match.R -\name{re2_match} -\alias{re2_match} -\alias{re2_match_all} -\title{Find matched groups from strings.} -\usage{ -re2_match(string, pattern, anchor = UNANCHORED, parallel = FALSE, - grain_size = 1e+05, ...) - -re2_match_all(string, pattern, anchor = UNANCHORED, parallel = FALSE, - grain_size = 1e+05, ...) -} -\arguments{ -\item{string}{a character vector} - -\item{pattern}{a pre-compiled regular expression or a string} - -\item{anchor}{UNANCHORED: no anchor. ANCHOR_START: anchor match at the beginning of the string. ANCHOR_BOTH: anchor match at the beginning and the end of the string.} - -\item{parallel}{multithreading support} - -\item{grain_size}{a minimum chunk size for tuning the behavior of parallel algorithms.} - -\item{...}{further arguments passed to or from other methods.} -} -\description{ -Find matched groups from strings. -} -\examples{ - -test_string = "this is just one test"; -re2_match(test_string, "(o.e)") - -(res = re2_match(test_string, "(o.e)")) -str(res) - -(res = re2_match(test_string, "(?Pthis)( is)")) -str(res) - -(res = re2_match_all(test_string, "(is)")) - -test_string = c("this is just one test", "the second test"); -(res = re2_match_all(test_string, "(is)")) - -test_string = c("this is just one test", "the second test") -(res = re2_match(test_string, "is")) - -regexp = re2("test",case_sensitive = FALSE) -re2_match("TEST", regexp) - -} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/match.R +\name{re2_match} +\alias{re2_match} +\alias{re2_match_all} +\title{Find matched groups from strings.} +\usage{ +re2_match(string, pattern, anchor = UNANCHORED, parallel = FALSE, + grain_size = 1e+05, ...) + +re2_match_all(string, pattern, anchor = UNANCHORED, parallel = FALSE, + grain_size = 1e+05, ...) +} +\arguments{ +\item{string}{a character vector} + +\item{pattern}{a pre-compiled regular expression or a string} + +\item{anchor}{UNANCHORED: no anchor. ANCHOR_START: anchor match at the beginning of the string. ANCHOR_BOTH: anchor match at the beginning and the end of the string.} + +\item{parallel}{multithreading support} + +\item{grain_size}{a minimum chunk size for tuning the behavior of parallel algorithms.} + +\item{...}{further arguments passed to or from other methods.} +} +\description{ +Find matched groups from strings. +} +\examples{ + +test_string = "this is just one test"; +re2_match(test_string, "(o.e)") + +(res = re2_match(test_string, "(o.e)")) +str(res) + +(res = re2_match(test_string, "(?Pthis)( is)")) +str(res) + +(res = re2_match_all(test_string, "(is)")) + +test_string = c("this is just one test", "the second test"); +(res = re2_match_all(test_string, "(is)")) + +test_string = c("this is just one test", "the second test") +(res = re2_match(test_string, "is")) + +regexp = re2("test",case_sensitive = FALSE) +re2_match("TEST", regexp) + +} + diff --git a/man/re2_replace.Rd b/man/re2_replace.Rd index 3cd432e..f9e5bb8 100644 --- a/man/re2_replace.Rd +++ b/man/re2_replace.Rd @@ -1,42 +1,42 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/replace.R -\name{re2_replace} -\alias{re2_replace} -\alias{re2_replace_all} -\title{Replace a pattern in strings.} -\usage{ -re2_replace(string, pattern, replacement, parallel = FALSE, - grain_size = 1e+05, ...) - -re2_replace_all(string, pattern, replacement, parallel = FALSE, - grain_size = 1e+05, ...) -} -\arguments{ -\item{string}{input character vector} - -\item{pattern}{a pre-compiled regular expression or a string} - -\item{replacement}{replace the first match or all of the match of "pattern" in "input" with "rewrite"} - -\item{parallel}{use multithread} - -\item{grain_size}{a minimum chunk size for tuning the behavior of parallel algorithms} - -\item{...}{further arguments passed to or from other methods} -} -\value{ -a character vector -} -\description{ -Replace the first match of "pattern" in "str" with "rewrite". -Within "rewrite", backslash-escaped digits (\\1 to \\9) can be -used to insert text matching corresponding parenthesized group -from the pattern. \\0 in "rewrite" refers to the entire matching -text. Vectorised over string, pattern and replacement. -} -\examples{ -regexp = re2("b+") -re2_replace_all("yabba dabba doo", regexp,"d") == "yada dada doo" -re2_replace("yabba dabba doo", "b+","d") == "yada dabba doo" -} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/replace.R +\name{re2_replace} +\alias{re2_replace} +\alias{re2_replace_all} +\title{Replace a pattern in strings.} +\usage{ +re2_replace(string, pattern, replacement, parallel = FALSE, + grain_size = 1e+05, ...) + +re2_replace_all(string, pattern, replacement, parallel = FALSE, + grain_size = 1e+05, ...) +} +\arguments{ +\item{string}{input character vector} + +\item{pattern}{a pre-compiled regular expression or a string} + +\item{replacement}{replace the first match or all of the match of "pattern" in "input" with "rewrite"} + +\item{parallel}{use multithread} + +\item{grain_size}{a minimum chunk size for tuning the behavior of parallel algorithms} + +\item{...}{further arguments passed to or from other methods} +} +\value{ +a character vector +} +\description{ +Replace the first match of "pattern" in "str" with "rewrite". +Within "rewrite", backslash-escaped digits (\\1 to \\9) can be +used to insert text matching corresponding parenthesized group +from the pattern. \\0 in "rewrite" refers to the entire matching +text. Vectorised over string, pattern and replacement. +} +\examples{ +regexp = re2("b+") +re2_replace_all("yabba dabba doo", regexp,"d") == "yada dada doo" +re2_replace("yabba dabba doo", "b+","d") == "yada dabba doo" +} + diff --git a/man/re2_split.Rd b/man/re2_split.Rd index 8b388f3..0ad192d 100644 --- a/man/re2_split.Rd +++ b/man/re2_split.Rd @@ -1,33 +1,33 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/split.R -\name{re2_split} -\alias{re2_split} -\alias{re2_split_fixed} -\title{Split strings with a pattern.} -\usage{ -re2_split(string, pattern, part = Inf, parallel = FALSE, - grain_size = 1e+05, ...) - -re2_split_fixed(string, pattern, part, parallel = FALSE, grain_size = 1e+05, - ...) -} -\arguments{ -\item{string}{a character vector} - -\item{pattern}{a pre-compiled regular expression or a string} - -\item{part}{number of pieces to return. Default (Inf) uses all possible split positions.} - -\item{parallel}{use multithread} - -\item{grain_size}{a minimum chunk size for tuning the behavior of parallel algorithms} - -\item{...}{further arguments passed to or from other methods.} -} -\description{ -Split up a string into pieces. -} -\examples{ -re2_split("yabba dabba doo", " ") -} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/split.R +\name{re2_split} +\alias{re2_split} +\alias{re2_split_fixed} +\title{Split strings with a pattern.} +\usage{ +re2_split(string, pattern, part = Inf, parallel = FALSE, + grain_size = 1e+05, ...) + +re2_split_fixed(string, pattern, part, parallel = FALSE, grain_size = 1e+05, + ...) +} +\arguments{ +\item{string}{a character vector} + +\item{pattern}{a pre-compiled regular expression or a string} + +\item{part}{number of pieces to return. Default (Inf) uses all possible split positions.} + +\item{parallel}{use multithread} + +\item{grain_size}{a minimum chunk size for tuning the behavior of parallel algorithms} + +\item{...}{further arguments passed to or from other methods.} +} +\description{ +Split up a string into pieces. +} +\examples{ +re2_split("yabba dabba doo", " ") +} + diff --git a/man/re2_subset.Rd b/man/re2_subset.Rd index 5baf357..40d52a3 100644 --- a/man/re2_subset.Rd +++ b/man/re2_subset.Rd @@ -1,42 +1,42 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/subset.R -\name{re2_subset} -\alias{re2_subset} -\alias{re2_subset<-} -\title{Keep strings matching a pattern.} -\usage{ -re2_subset(input, pattern, anchor = 0, parallel = FALSE, - grain_size = 1e+05, ...) - -re2_subset(input, pattern, anchor = 0, parallel, grain_size, ...) <- value -} -\arguments{ -\item{pattern}{a pre-compiled regular expression or a string} - -\item{anchor}{UNANCHORED: no anchor. ANCHOR_START: anchor match at the beginning of the string. ANCHOR_BOTH: anchor match at the beginning and the end of the string.} - -\item{parallel}{use multithread} - -\item{grain_size}{a minimum chunk size for tuning the behavior of parallel algorithms} - -\item{...}{further arguments passed to or from other methods.} - -\item{value}{character vector to be substituted with; replacement function only} -} -\value{ -A character vector. -} -\description{ -This is a convenient wrapper around \code{x[re2_detect(x, pattern)]}. -} -\examples{ -fruit <- c("apple", "banana", "pear", "pinapple") -re2_subset(fruit, "a") -re2_subset(fruit, "^a") -re2_subset(fruit, "a$") -re2_subset(fruit, "b") -re2_subset(fruit, "[aeiou]") - -re2_subset(c("a", NA, "b"), ".") -} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/subset.R +\name{re2_subset} +\alias{re2_subset} +\alias{re2_subset<-} +\title{Keep strings matching a pattern.} +\usage{ +re2_subset(input, pattern, anchor = 0, parallel = FALSE, + grain_size = 1e+05, ...) + +re2_subset(input, pattern, anchor = 0, parallel, grain_size, ...) <- value +} +\arguments{ +\item{pattern}{a pre-compiled regular expression or a string} + +\item{anchor}{UNANCHORED: no anchor. ANCHOR_START: anchor match at the beginning of the string. ANCHOR_BOTH: anchor match at the beginning and the end of the string.} + +\item{parallel}{use multithread} + +\item{grain_size}{a minimum chunk size for tuning the behavior of parallel algorithms} + +\item{...}{further arguments passed to or from other methods.} + +\item{value}{character vector to be substituted with; replacement function only} +} +\value{ +A character vector. +} +\description{ +This is a convenient wrapper around \code{x[re2_detect(x, pattern)]}. +} +\examples{ +fruit <- c("apple", "banana", "pear", "pinapple") +re2_subset(fruit, "a") +re2_subset(fruit, "^a") +re2_subset(fruit, "a$") +re2_subset(fruit, "b") +re2_subset(fruit, "[aeiou]") + +re2_subset(c("a", NA, "b"), ".") +} + diff --git a/man/show_regex.Rd b/man/show_regex.Rd index e418716..3cb4c6a 100644 --- a/man/show_regex.Rd +++ b/man/show_regex.Rd @@ -1,52 +1,52 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/widget.R -\name{show_regex} -\alias{show_regex} -\title{Show regex pattern in a htmlwidget} -\usage{ -show_regex(pattern, width = NULL, height = NULL) -} -\arguments{ -\item{pattern}{a pattern string} - -\item{width}{the widget width} - -\item{height}{the widget height} -} -\description{ -Show JS-style regex pattern in an htmlwidget. -} -\details{ -Most parts of RE2 regex syntax are supported, except for some special Unicode character classes. -} -\examples{ -# Skip on CRAN - -\dontrun{ - -# US ZIP code - -show_regex("[0-9]{5}(?:-[0-9]{4})?") - -# Email - -show_regex("\\\\b[a-zA-Z0-9._\%-]+@[a-zA-Z0-9.-]+\\\\.[a-zA-Z]{2,4}\\\\b") - -# Hex value - -show_regex("#?([a-f0-9]{6}|[a-f0-9]{3})") - -# URL - -show_regex("((www\\\\.|(http|https|ftp|news|file)+\\\\:\\\\/\\\\/)[_.a-z0-9-]+\\\\.[a-z0-9\\\\/_:@=.+?,##\%&~-]*[^.|\\\\'|\\\\# |!|\\\\(|?|,| |>|<|;|\\\\)])") - -# major credit cards - -show_regex("^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|622((12[6-9]|1[3-9][0-9])|([2-8][0-9][0-9])|(9(([0-1][0-9])|(2[0-5]))))[0-9]{10}|64[4-9][0-9]{13}|65[0-9]{14}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})*$") -} - -} -\seealso{ -https://regexper.com/documentation.html -} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/widget.R +\name{show_regex} +\alias{show_regex} +\title{Show regex pattern in a htmlwidget} +\usage{ +show_regex(pattern, width = NULL, height = NULL) +} +\arguments{ +\item{pattern}{a pattern string} + +\item{width}{the widget width} + +\item{height}{the widget height} +} +\description{ +Show JS-style regex pattern in an htmlwidget. +} +\details{ +Most parts of RE2 regex syntax are supported, except for some special Unicode character classes. +} +\examples{ +# Skip on CRAN + +\dontrun{ + +# US ZIP code + +show_regex("[0-9]{5}(?:-[0-9]{4})?") + +# Email + +show_regex("\\\\b[a-zA-Z0-9._\%-]+@[a-zA-Z0-9.-]+\\\\.[a-zA-Z]{2,4}\\\\b") + +# Hex value + +show_regex("#?([a-f0-9]{6}|[a-f0-9]{3})") + +# URL + +show_regex("((www\\\\.|(http|https|ftp|news|file)+\\\\:\\\\/\\\\/)[_.a-z0-9-]+\\\\.[a-z0-9\\\\/_:@=.+?,##\%&~-]*[^.|\\\\'|\\\\# |!|\\\\(|?|,| |>|<|;|\\\\)])") + +# major credit cards + +show_regex("^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|622((12[6-9]|1[3-9][0-9])|([2-8][0-9][0-9])|(9(([0-1][0-9])|(2[0-5]))))[0-9]{10}|64[4-9][0-9]{13}|65[0-9]{14}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})*$") +} + +} +\seealso{ +https://regexper.com/documentation.html +} + diff --git a/man/sub_string.Rd b/man/sub_string.Rd index 9c43428..caf0491 100644 --- a/man/sub_string.Rd +++ b/man/sub_string.Rd @@ -1,40 +1,40 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/substring.R -\name{sub_string} -\alias{sub_string} -\alias{sub_string<-} -\title{Extract and replace substrings from a character vector.} -\usage{ -sub_string(string, from = 1L, to = -1L) - -sub_string(string, from = 1L, to = -1L) <- value -} -\arguments{ -\item{string}{input character vector.} - -\item{from}{an integer vector or a two-column matrix. \code{from} gives the position of the first character (defaults to first). Negative values count backwards from the last character.} - -\item{to}{an integer vector. \code{to} gives the position of the last (defaults to last character).} - -\item{value}{replacement string} -} -\value{ -A character vector of substring from \code{start} to \code{end} - (inclusive). Will be length of longest input argument. -} -\description{ -\code{sub_string} extracts substrings under code point-based index ranges provided. \code{sub_string<-} allows to substitute parts of a string with given strings. -} -\examples{ -sub_string("test", 1, 2) - -x <- "ABC" - -(sub_string(x, 1, 1) <- "A") -(sub_string(x, -2, -2) <- "GHIJ") -(sub_string(x, 2, -2) <- "") -} -\seealso{ -The underlying implementation in \code{\link[stringi]{stri_sub}} -} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/substring.R +\name{sub_string} +\alias{sub_string} +\alias{sub_string<-} +\title{Extract and replace substrings from a character vector.} +\usage{ +sub_string(string, from = 1L, to = -1L) + +sub_string(string, from = 1L, to = -1L) <- value +} +\arguments{ +\item{string}{input character vector.} + +\item{from}{an integer vector or a two-column matrix. \code{from} gives the position of the first character (defaults to first). Negative values count backwards from the last character.} + +\item{to}{an integer vector. \code{to} gives the position of the last (defaults to last character).} + +\item{value}{replacement string} +} +\value{ +A character vector of substring from \code{start} to \code{end} + (inclusive). Will be length of longest input argument. +} +\description{ +\code{sub_string} extracts substrings under code point-based index ranges provided. \code{sub_string<-} allows to substitute parts of a string with given strings. +} +\examples{ +sub_string("test", 1, 2) + +x <- "ABC" + +(sub_string(x, 1, 1) <- "A") +(sub_string(x, -2, -2) <- "GHIJ") +(sub_string(x, 2, -2) <- "") +} +\seealso{ +The underlying implementation in \code{\link[stringi]{stri_sub}} +} + diff --git a/re2r.Rproj b/re2r.Rproj index 6972c81..35300da 100644 --- a/re2r.Rproj +++ b/re2r.Rproj @@ -1,23 +1,23 @@ -Version: 1.0 - -RestoreWorkspace: Default -SaveWorkspace: Default -AlwaysSaveHistory: Default - -EnableCodeIndexing: Yes -UseSpacesForTab: Yes -NumSpacesForTab: 4 -Encoding: UTF-8 - -RnwWeave: knitr -LaTeX: pdfLaTeX - -AutoAppendNewline: Yes -StripTrailingWhitespace: Yes -LineEndingConversion: Posix - -BuildType: Package -PackageUseDevtools: Yes -PackageInstallArgs: --no-multiarch --with-keep.source -PackageCheckArgs: --no-vignettes -PackageRoxygenize: rd,collate,namespace +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 4 +Encoding: UTF-8 + +RnwWeave: knitr +LaTeX: pdfLaTeX + +AutoAppendNewline: Yes +StripTrailingWhitespace: Yes +LineEndingConversion: Posix + +BuildType: Package +PackageUseDevtools: Yes +PackageInstallArgs: --no-multiarch --with-keep.source +PackageCheckArgs: --no-vignettes +PackageRoxygenize: rd,collate,namespace