@@ -46,12 +46,13 @@ str_extract <- function(string, pattern, group = NULL) {
4646 }
4747
4848 check_lengths(string , pattern )
49+ opt <- opts(pattern )
4950 out <- switch (type(pattern ),
50- empty = stri_extract_first_boundaries(string , opts_brkiter = opts( pattern ) ),
51- bound = stri_extract_first_boundaries(string , opts_brkiter = opts( pattern ) ),
52- fixed = stri_extract_first_fixed(string , pattern , opts_fixed = opts( pattern ) ),
53- coll = stri_extract_first_coll(string , pattern , opts_collator = opts( pattern ) ),
54- regex = stri_extract_first_regex(string , pattern , opts_regex = opts( pattern ) )
51+ empty = stri_extract_first_boundaries(string , opts_brkiter = opt ),
52+ bound = stri_extract_first_boundaries(string , opts_brkiter = opt ),
53+ fixed = stri_extract_first_fixed(string , pattern , opts_fixed = opt ),
54+ coll = stri_extract_first_coll(string , pattern , opts_collator = opt ),
55+ regex = stri_extract_first_regex(string , pattern , opts_regex = opt )
5556 )
5657 if (length(out ) == length(string )) names(out ) <- names(string )
5758 out
@@ -63,17 +64,18 @@ str_extract_all <- function(string, pattern, simplify = FALSE) {
6364 check_lengths(string , pattern )
6465 check_bool(simplify )
6566
67+ opt <- opts(pattern )
6668 out <- switch (type(pattern ),
6769 empty = stri_extract_all_boundaries(string ,
68- simplify = simplify , omit_no_match = TRUE , opts_brkiter = opts( pattern ) ),
70+ simplify = simplify , omit_no_match = TRUE , opts_brkiter = opt ),
6971 bound = stri_extract_all_boundaries(string ,
70- simplify = simplify , omit_no_match = TRUE , opts_brkiter = opts( pattern ) ),
72+ simplify = simplify , omit_no_match = TRUE , opts_brkiter = opt ),
7173 fixed = stri_extract_all_fixed(string , pattern ,
72- simplify = simplify , omit_no_match = TRUE , opts_fixed = opts( pattern ) ),
74+ simplify = simplify , omit_no_match = TRUE , opts_fixed = opt ),
7375 coll = stri_extract_all_coll(string , pattern ,
74- simplify = simplify , omit_no_match = TRUE , opts_collator = opts( pattern ) ),
76+ simplify = simplify , omit_no_match = TRUE , opts_collator = opt ),
7577 regex = stri_extract_all_regex(string , pattern ,
76- simplify = simplify , omit_no_match = TRUE , opts_regex = opts( pattern ) )
78+ simplify = simplify , omit_no_match = TRUE , opts_regex = opt )
7779 )
7880 if (simplify ) {
7981 rownames(out ) <- names(string )
0 commit comments