Skip to content

Commit 53e82c1

Browse files
Update split compound field function to allow for special characters
1 parent 46aa651 commit 53e82c1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

R/flag_standardizing_script.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ standardize_locations <- function(input_locations, flag_lookup_table){
127127
#' split_dates <- split_compound_field(c("1960-01-01", "2024-04-04"), c("-", "-"), "separators")
128128
#' @export
129129
split_compound_field <- function(compound_field, split_objects, split_type){
130+
# Replace special escape characters (like ^) with valid ones
131+
for (i in seq_along(split_objects)) {
132+
split_pattern <- split_objects[i]
133+
split_pattern <- str_replace_all(split_pattern, "(\\^)", "\\\\\\1")
134+
split_objects[i] <- split_pattern
135+
}
136+
130137
if(split_type == "separators"){
131138
compound_field <- t(compound_field)
132139
name_split <- vector("list", length(split_objects) + 1)

0 commit comments

Comments
 (0)