我想让方括号之间的字符。
这是我的数据示例。
mysql> select * from Users;
+----+----------------+----------+----------+---------------------+
| ID | Email | UserName | Password | DateRegistered |
+----+----------------+----------+----------+---------------------+
| 1 | test@test.com | tester | dank | 2019-02-26 22:43:26 |
| 2 | test2@test.com | 2tester | dank | 2019-02-26 22:43:26 |
+----+----------------+----------+----------+---------------------+
想要的输出:select
Title,
Users.ID as Author,
SubmissionTime as Posted
from ForumPosts
left join
Users on ForumPosts.UserID = Users.ID
order by SubmissionTime desc;
谢谢
答案 0 :(得分:2)
我们可以使用str_extract
并将其与正则表达式匹配。在这里,我们使用与(?<=\\[
相匹配的正则表达式查询([
),后跟一个或多个数字(\\d+
)和非]
的字符({{1 }})
[^]]+
library(stringr)
str_extract(str1, "(?<=\\[)\\d+[^]]+")
#[1] "34BND001"
要了解此表达式,您可以进一步搜索正则表达式(正则表达式)