Создание разрывов строк на основе регулярного выражения в R

Я новичок в R. Я извлек текст из сети и вставил в текстовый файл. Они выглядят так.

    c("HR name as meena in malad west branch first source ltd called me for interview as openings in llyods chat process as banking process she told me 3 rounds of interview and other hr vl ask me these questions.As she said there r openings but when other hr taken my interview she told there r no...", 
"", "", "Sir with due respect from 7 nov 2015, i dont receive my sms alerts from my registered mobile number as 9596159288 . ", 
"Account name Tariq Ahmad Mir", "Branch: WATRIGAM", "Contact: 1954-235307", 
"", "IFSC Code: SBIN0004591 ", "", "", "MICR Code: 193002321..."

Каждый из этих комментариев отделяется "..." в конце комментария. Я пытался объединить каждый комментарий в одну строку. Я попробовал следующий код:

a <- readLines("banking1.txt", warn = FALSE)
a <- a[sapply(a, nchar) > 0]
a <- paste(a, collapse = ",")

который дал мне вывод следующим образом:

"HR name as meena in malad west branch first source ltd called me for interview as openings in llyods chat process as banking process she told me 3 rounds of interview and other hr vl ask me these questions.As she said there r openings but when other hr taken my interview she told there r no...,Sir with due respect from 7 nov 2015, i dont receive my sms alerts from my registered mobile number as 9596159288 . ,Account name Tariq Ahmad Mir,Branch: WATRIGAM,Contact: 1954-235307,IFSC Code: SBIN0004591 ,MICR Code: 193002321..."

Я пытаюсь разделить их, используя... разделитель.

a <- strsplit(a, "...,")
a <- strsplit(a, "...,")[[1]]
a <- noquote(strsplit(a, "...,")[[1]]) 

и много других подобных опций. Но выход не то, что я ожидаю. Что мне нужно

HR name as meena in malad west branch first source ltd called me for interview as openings in llyods chat process as banking process she told me 3 rounds of interview and other hr vl ask me these questions.As she said there r openings but when other hr taken my interview she told there r no...
Sir with due respect from 7 nov 2015, i dont receive my sms alerts from my registered mobile number as 9512139288 . Account name Tariq Ahmad Mir Branch: MAGRITAW Contact: 1954-235307 IFSC Code: AVCN0001234 MICR Code: 19300321...

Может кто-нибудь помочь?

1 ответ

Решение

Вы можете использовать отрицательный взгляд сзади.

x <- c("HR name as meena in malad west branch first source ltd called me for interview as openings in llyods chat process as banking process she told me 3 rounds of interview and other hr vl ask me these questions.As she said there r openings but when other hr taken my interview she told there r no...", 
  "", "", "Sir with due respect from 7 nov 2015, i dont receive my sms alerts from my registered mobile number as 9596159288 . ", 
  "Account name Tariq Ahmad Mir", "Branch: WATRIGAM", "Contact: 1954-235307", 
  "", "IFSC Code: SBIN0004591 ", "", "", "MICR Code: 193002321...")
y <- paste(x, collapse="\n")
z <- gsub("(?<!\\.{3})\\n+", " ", y, perl=TRUE) 
z <- strsplit(z, "\n")

DEMO

Другие вопросы по тегам