Skip to content

Commit

Permalink
addressing #31
Browse files Browse the repository at this point in the history
  • Loading branch information
JBGruber committed Dec 1, 2023
1 parent 6c12c6b commit bced4e1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion R/rwhatsapp.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit bced4e1

Please sign in to comment.