I expect the following code to recognize all the patterns (pat1, pat2, pat3, pat4). However, this recognize only the 'pat4'. How should I modify my code?
test.pat<-"pat1|pat2|pat3|((?<=abcd)(.|\n)*pat4)"
originalTXT<-"start abcd pat1 pat2 pat3 pat4"
gregexpr(test.pat, originalTXT, perl=TRUE)
[[1]]
[1] 11
attr(,"match.length")
[1] 20
attr(,"useBytes")
[1] TRUE
attr(,"capture.start")
[1,] 11 26
attr(,"capture.length")
[1,] 20 1
attr(,"capture.names")
[1] "" ""
If I omit the "pat4" which used 'positive lookbehind', there's no problem.
test.pat<-"pat1|pat2|pat3"
originalTXT<-"start abcd pat1 pat2 pat3 pat4"
gregexpr(test.pat, originalTXT, perl=TRUE)
[[1]]
[1] 12 17 22
attr(,"match.length")
[1] 4 4 4
attr(,"useBytes")
[1] TRUE