【发布时间】:2014-08-24 07:22:26
【问题描述】:
我需要在R中提取以下模式
(10 digits), prefix with 3, 5, 9 (e.g. 3234567890, 5234567890, 9234567890)
(10 digits), prefix with 4 (e.g. 4234567890)
(10 digits), prefix with 8 (e.g. 8234567890)
及以下
TAM(5 digits) – e.g. TAM12345 (numbers starting with TAM and 5 digits)
E(7 digits) – e.g. E1234567 (numbers starting with E and only 7 digits)
A(5 digits) – e.g. A12345 (numbers starting with A and only 5 digits)
我使用 stingr 库。
我能够提取数字(带字母)- 不知道如何给出特定的前缀并限制数字
邮件在下方
These are the notice number - with high priority
3234567890 and 5234567890 and the long pending issue 9234567890 along with the discuused numbers 4234567890,8234567890.
Special messages from TAM12345,E1234567 and A12345
需要的输出
3234567890, 5234567890, 9234567890
4234567890
8234567890
TAM12345
E1234567
A12345
【问题讨论】:
-
@Mr.Flick 我在 R.I 中使用来自
stringr包的str_extract_all。我正在尝试通过这个函数找到相同的方法 -
提供样本输入的字符向量以及所需的输出会更有帮助。因为
str_extract_all接受正则表达式作为模式参数。 -
@Prasanna Nandakumar。字符和数字之间是否有空格,例如
discuused numbers4234567890? -
编辑问题,字符和数字之间有空格