这个正则表达式:
str_extract_all("This is a Test , ' ' " , "[a-z]+")
返回:
[1] "his" "is" "a" "est"
如何修改使其不区分大小写?
`[1] "This" "is" "a" "Test"`
应该返回
Should /i
删除区分大小写?
Trying str_extract_all("This is a Test , ' ' " , "[a-z]+/i")
returns
[[1]]
character(0)
有一个特殊的记号stringr功能 https://cran.r-project.org/web/packages/stringr/stringr.pdf:
regex(pattern, ignore_case = FALSE, multiline = FALSE, comments = FALSE,
dotall = FALSE, ...)
您可以使用
> str_extract_all("This is a Test , ' ' " , regex("[a-z]+", ignore_case=TRUE))
[[1]]
[1] "This" "is" "a" "Test"
或者,使用内联i
修饰语(?i)
:
str_extract_all("This is a Test , ' ' " , "(?i)[a-z]+")
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)