writeLines(captureAll(expression(1+1)))
writeLines(captureAll(expression(1+1), split = TRUE))
writeLines(captureAll(parseText("search()")))
writeLines(captureAll(parseText('1:2 + 1:3')))
writeLines(captureAll(parseText("badname")))
## Management of incomplete lines
captRes <- captureAll(parseText("1 +")) # Clearly an incomplete command
if (is.na(captRes)) cat("Incomplete line!
") else writeLines(res)
rm(captRes)
Run the code above in your browser using DataLab