| nth_number_before_mth {filesstrings} | R Documentation |
Given a string, a pattern and natural numbers n and m, find the nth
number that comes before the mth occurrence of the pattern.
nth_number_before_mth(string, pattern, n, m, decimals = FALSE, leading_decimals = FALSE, negs = FALSE, leave_as_string = FALSE) nth_number_before_first(string, pattern, n, decimals = FALSE, leading_decimals = FALSE, negs = FALSE, leave_as_string = FALSE) nth_number_before_last(string, pattern, n, decimals = FALSE, leading_decimals = FALSE, negs = FALSE, leave_as_string = FALSE) first_number_before_mth(string, pattern, m, decimals = FALSE, leading_decimals = FALSE, negs = FALSE, leave_as_string = FALSE) last_number_before_mth(string, pattern, m, decimals = FALSE, leading_decimals = FALSE, negs = FALSE, leave_as_string = FALSE) first_number_before_first(string, pattern, decimals = FALSE, leading_decimals = FALSE, negs = FALSE, leave_as_string = FALSE) first_number_before_last(string, pattern, decimals = FALSE, leading_decimals = FALSE, negs = FALSE, leave_as_string = FALSE) last_number_before_first(string, pattern, decimals = FALSE, leading_decimals = FALSE, negs = FALSE, leave_as_string = FALSE) last_number_before_last(string, pattern, decimals = FALSE, leading_decimals = FALSE, negs = FALSE, leave_as_string = FALSE)
string |
A character vector. |
pattern |
A character vector. Pattern(s) specified like the pattern(s)
in the stringr package (e.g. look at |
n, m |
Natural numbers. |
decimals |
Do you want to include the possibility of decimal numbers
( |
leading_decimals |
Do you want to allow a leading decimal point to be the start of a number? |
negs |
Do you want to allow negative numbers? Note that double negatives are not handled here (see the examples). |
leave_as_string |
Do you want to return the number as a string ( |
A numeric vector.
string <- c("abc1abc2abc3abc4def5abc6abc7abc8abc9",
"abc1def2ghi3abc4def5ghi6abc7def8ghi9")
nth_number_before_mth(string, "def", 1, 1)
nth_number_before_mth(string, "abc", 2, 3)
nth_number_before_first(string, "def", 2)
nth_number_before_last(string, "def", -1)
first_number_before_mth(string, "abc", 2)
last_number_before_mth(string, "def", 1)
first_number_before_first(string, "def")
first_number_before_last(string, "def")
last_number_before_first(string, "def")
last_number_before_last(string, "def")