diff --git a/R/rwhatsapp.R b/R/rwhatsapp.R index a8e781a..31578b9 100755 --- a/R/rwhatsapp.R +++ b/R/rwhatsapp.R @@ -48,7 +48,7 @@ rwa_read <- function(x, chat_raw <- chat_raw[!chat_raw == ""] time <- stri_extract_first_regex( str = chat_raw, - pattern = "^\\d{2,4}.\\d{2}.\\d{2,4} - \\d{2}:\\d{2}[^;]+;|^\\d{2,4}-\\d{2}-\\d{2,4}[^-]+ -|[^-]+ - " + pattern = "^\\d{2,4}.\\d{2}.\\d{2,4} - \\d{2}:\\d{2}[^;]+;|^\\d{2,4}-\\d{2}-\\d{2,4}[^-]+ -" ) if (sum(is.na(time)) > (length(time) * 0.9)) { time <- stri_extract_first_regex(str = chat_raw, @@ -60,6 +60,12 @@ rwa_read <- function(x, pattern = "^[^A-z]*\\d{1,2}:\\d{1,2}(\\sAM|\\sPM){0,1}" ) } + if (sum(is.na(time)) > (length(time) * 0.9)) { + time <- stri_extract_first_regex( + str = chat_raw, + pattern = "[^-]+ - " + ) + } proper_time <- stri_detect_regex( str = time,