Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想检查 R 中的字符串是否具有这种格式
NNNN__NNN
即四个数字(N代表任何数字[0,9]),两个下划线,3个数字。
有什么帮助吗?
非常感谢
grepl("\\d{4}__\\d{3}","1234__12reg3")
返回 False
grepl("\\d{4}__\\d{3}","1234__123")
返回真
\d 是正则表达式中的数字。你应该看看 ?grepl