Description Usage Arguments Details Value See Also Examples
These functions find the indices, at which a given pattern matches a substring of the input string.
1 2 3 4 5 | stri_locate_all_fixed(str, pattern, opts_collator = list())
stri_locate_first_fixed(str, pattern, opts_collator = list())
stri_locate_last_fixed(str, pattern, opts_collator = list())
|
str |
character vector |
pattern |
character vector |
opts_collator |
a named list as generated with
|
Vectorized over str and pattern.
See stringi-search-fixed for more details on Locale-Sensitive Text Searching in stringi.
Note the difference between stri_locate_last_fixed
and stri_locate_last_regex for overlapping
pattern matches. In stri_locate_last_fixed, search
is done from-the-end.
Pass opts_collator equal to NA for much
faster, but locale unaware, (exact) bitwise comparisons.
For a natural language text this may be not what you really
want.
For stri_locate_all_charclass, a list of
max(length(str), length(pattern)) integer matrices
is returned . The first column gives the start positions of
matches, and the second column gives the end position.
Moreover, you may gen two NAs in one row for no
match or NA arguments.
For stri_locate_first_fixed and
stri_locate_last_fixed, you get an integer matrix
with max(length(str), length(pattern)) rows, and two
columns, giving the start and end positions of the first or
the last matches, respectively, and NAs iff not
found.
Other indexing: stri_locate_all_charclass,
stri_locate_all_charclass,
stri_locate_first_charclass,
stri_locate_first_charclass,
stri_locate_last_charclass,
stri_locate_last_charclass;
stri_locate_all_regex,
stri_locate_all_regex,
stri_locate_first_regex,
stri_locate_first_regex,
stri_locate_last_regex,
stri_locate_last_regex;
stri_locate_all;
stri_locate_first;
stri_locate_last; stri_locate;
stri_sub, stri_sub<-
Other locale_sensitive: stri_cmp,
stri_compare; stri_count_fixed;
stri_detect_fixed;
stri_enc_detect2;
stri_opts_collator; stri_order,
stri_sort;
stri_replace_all_fixed,
stri_replace_all_fixed,
stri_replace_first_fixed,
stri_replace_first_fixed,
stri_replace_last_fixed,
stri_replace_last_fixed;
stri_split_fixed,
stri_split_fixed;
stri_trans_tolower,
stri_trans_totitle,
stri_trans_toupper;
stringi-locale;
stringi-search-fixed
Other search_fixed: stri_count_fixed;
stri_detect_fixed;
stri_extract_all_fixed,
stri_extract_all_fixed,,
stri_extract_first_fixed,
stri_extract_first_fixed,,
stri_extract_last_fixed,
stri_extract_last_fixed;
stri_opts_collator;
stri_replace_all_fixed,
stri_replace_all_fixed,
stri_replace_first_fixed,
stri_replace_first_fixed,
stri_replace_last_fixed,
stri_replace_last_fixed;
stri_split_fixed,
stri_split_fixed;
stringi-search-fixed;
stringi-search
Other search_locate: stri_extract_all_fixed,
stri_extract_all_fixed,,
stri_extract_first_fixed,
stri_extract_first_fixed,,
stri_extract_last_fixed,
stri_extract_last_fixed;
stri_locate_all_charclass,
stri_locate_all_charclass,
stri_locate_first_charclass,
stri_locate_first_charclass,
stri_locate_last_charclass,
stri_locate_last_charclass;
stri_locate_all_regex,
stri_locate_all_regex,
stri_locate_first_regex,
stri_locate_first_regex,
stri_locate_last_regex,
stri_locate_last_regex;
stri_locate_all;
stri_locate_first;
stri_locate_last; stri_locate;
stringi-search
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ## Not run:
stri_locate_all_fixed(c('AaaaaaaA', 'AAAA'), 'a')
stri_locate_first_fixed(c('AaaaaaaA', 'aaa', 'AAA'), 'a')
stri_locate_last_fixed(c('AaaaaaaA', 'aaa', 'AAA'), 'a')
#first row is 1-2 like in locate_first
stri_locate_all_fixed('bbbbb', 'bb')
stri_locate_first_fixed('bbbbb', 'bb')
# but last row is 3-4, unlike in locate_last,
# keep this in mind [overlapping pattern match OK]!
stri_locate_last_fixed('bbbbb', 'bb')
locate <- stri_locate_first_fixed('stringi - REXAMINE', letters)
rownames(locate) <- letters
locate
## End(Not run)
|
[[1]]
start end
[1,] 2 2
[2,] 3 3
[3,] 4 4
[4,] 5 5
[5,] 6 6
[6,] 7 7
[[2]]
start end
[1,] NA NA
start end
[1,] 2 2
[2,] 1 1
[3,] NA NA
start end
[1,] 7 7
[2,] 3 3
[3,] NA NA
[[1]]
start end
[1,] 1 2
[2,] 3 4
start end
[1,] 1 2
start end
[1,] 4 5
start end
a NA NA
b NA NA
c NA NA
d NA NA
e NA NA
f NA NA
g 6 6
h NA NA
i 4 4
j NA NA
k NA NA
l NA NA
m NA NA
n 5 5
o NA NA
p NA NA
q NA NA
r 3 3
s 1 1
t 2 2
u NA NA
v NA NA
w NA NA
x NA NA
y NA NA
z NA NA
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.