x2 <- x[nzchar(x)]
x3 <- split(x2, cumsum(grepl("^[A-Z]", x2)))
x4 <- lapply(x3, function(z) transform(strcapture("^([0-9]+)\s+([^:]+):\s*(.*)$", z[-1], list(num="", title="", desc="")), name=z[1]))
x5 <- do.call(rbind, x4)
x5
# num title desc name
# 1.1 001 Chief Executive Officer Job description of CEO. EXECUTIVE LEVEL
# 1.2 040 Area Director This line contains job description of the Area Director. EXECUTIVE LEVEL
# 2.1 025 Chief Operating Officer This line contains job description of the Chief Operating Officer FINANCE TEAM
# 2.2 055 Chief Financial Officer This person controls operations of the company and reports to the COO FINANCE TEAM
# 3 056 Marketing Director This person is in charge of the marketing team. Blab la bla MARKETING TEAM
Data, likely the results of x <- readLines(path_to_file)
.
x <- c("EXECUTIVE LEVEL", "001 Chief Executive Officer: Job description of CEO.", "040 Area Director: This line contains job description of the Area Director.", "", "FINANCE TEAM", "025 Chief Operating Officer: This line contains job description of the Chief Operating Officer", "055 Chief Financial Officer: This person controls operations of the company and reports to the COO", "", "MARKETING TEAM", "056 Marketing Director: This person is in charge of the marketing team. Blab la bla")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…