Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 为什么这个正则表达式在R中使用lookbehinds无效?_Regex_R - Fatal编程技术网

Regex 为什么这个正则表达式在R中使用lookbehinds无效?

Regex 为什么这个正则表达式在R中使用lookbehinds无效?,regex,r,Regex,R,我正试图在R中查找正则表达式以找到一个模式。我想这会把“bob”中的“b”拉出来,但是我得到了一个错误 > regexpr("(?<=a)b","thingamabob") Error in regexpr("(?<=a)b", "thingamabob") : invalid regular expression '(?<=a)b', reason 'Invalid regexp' >regexpr((?你只需要通过设置PERL=TRUE来切换到PERL正则表达式,

我正试图在R中查找正则表达式以找到一个模式。我想这会把“bob”中的“b”拉出来,但是我得到了一个错误

> regexpr("(?<=a)b","thingamabob")
Error in regexpr("(?<=a)b", "thingamabob") : 
invalid regular expression '(?<=a)b', reason 'Invalid regexp'

>regexpr((?你只需要通过设置
PERL=TRUE

来切换到PERL正则表达式,哦,文档……试试设置
PERL=TRUE
。哦,好吧,但是这样的问题得到rep让我觉得很肮脏。@joran如果这能让你感觉好些,我们都可以否决你?;)@Dason如果你愿意花这笔钱来减轻我的内疚感,我绝对不会挡你的路!:)如果你想从a之后的第一个b获得所有东西,那么这将不需要回头看:
library(gsubfn);Straplyc(“thingamabob”,“a(b*))
不管问题多么简单。我仍然缺少这一小部分。谢谢。@joran,你能解释一下
Perl
到底在做什么吗?我搜索并找到了这个
Perl:logical。是否应该使用与Perl兼容的正则表达式?这里的优先级高于扩展的
。但我仍然不清楚
> regexpr("(.<=a)b","thingamabob")
[1] -1
attr(,"match.length")
[1] -1
attr(,"useBytes")
[1] TRUE