中工作我试过grep,grepl,regexpr,gregexpr和所有返回失败或非整数。为什么这个正则表达式不能在R
Ojbect是“test”,它是一个带地址的字符串。例如提供:
[9972] "1350 Hwy 160 W\nFort Mill, SC 29715"
[9973] "Sonoran Desert Dentistry\n9220 E Raintree Dr\nSte 102\nScottsdale, AZ 85260"
[9974] "3252 Vilas Rd\nCottage Grove, WI 53527"
[9975] "224 W Cottage Grove Rd\nCottage Grove, WI 53527"
[9976] "320 W Cottage Grove Rd\nCottage Grove, WI 53527"
[9977] "7914 State Road 19\nDane, WI 53529"
[9978] "106 Dane St\nDane, WI 53529"
的目标是在最后的“\ n”所以只是我市通过邮编保持提取的一切。像“山寨格罗夫,WI 53527”
这里是行不通的grep和正则表达式的样本:
> grep("\\[^\\]+$", test)
integer(0)
任何帮助将是巨大的。
有这些文本行没有反斜杠。您需要知道,使用转义字符的字符值的“print”输出与“cat”输出不同。阅读'?Quotes'并尝试一些线路上的'cat'。 (...我认为''[^ \\]“'会与任何东西匹配。) –