Custom grep implementation with libpcre