in reply to Regex text extraction b/w first intance of pattern X and third instance of pattern Y.
The "third instance of c" really means "everything not a c plus a c, plus everything not a c plus c, plus everything not a c upto but excluding the next c":
"abcbcbc" =~ m[ a ( [^c]* c [^c]* c [^c]* ) c ]x and print "'$1'";; 'bcbcb' ## or "abcbcbc" =~ m[a((?:[^c]*c){2}[^c]*)c] and print "'$1'";; 'bcbcb'
|
|---|