r - R:如何将字符串分成几部分
问题描述
解决方案
You can try with str_extract_all
:
stringr::str_extract_all(x, '[A-Za-z_]+')[[1]]
[1] "CN" "Shandong" "Zibo" "ABCDEFGHIJK" "IMG_HAS"
With base R :
regmatches(x, gregexpr('[A-Za-z_]+', x))[[1]]
Here we extract all the words with upper, lower case or an underscore. Everything else is ignored so characters like �\\00?
are not there in final output.
推荐阅读
- sql - SQL windows 函数 LEAD/LAG 但只考虑某些值?
- python - 真正的随机 python 数字
- r - 带有长组标签的李克特量表调查结果的箱线图
- python - 如果语句的语法无效
- arrays - 错误:对象作为 React 子项无效。获取对象的对象而不是对象数组
- youtube-data-api - 通过代码接收原始 YouTube 视频比特流
- python - 从Dataframe中的字符串(列表)中过滤项目
- python - 在 SQLite 中根据今天的日期创建生成列
- python - PyGame角色不向左移动
- mysql - 如果我对非索引字段进行查询,是否使用全表扫描