doubleyin 发表于 2020-4-27 18:23 
不行 改之后还是报错而且str_match("514-791-8141", phone)识别也错了
R Markdown
phone <- regex("
\\(? # optional opening parens
(\\d{3}) # area code
[)-[:space:]]? # optional closing parens, dash, or space
(\\d{3}) # another three numbers
[[:space:]-]? # optional space or dash
(\\d{3}) # three more numbers
", comments = TRUE)
str_match("514 791 8141", phone)
## [,1] [,2] [,3] [,4]
## [1,] "514 791 814" "514" "791" "814"
# automatically throw out each group
这回可以啦