I suspect that you are having a problem with multi-line strings. A period does not match a newline (unless you use the /s flag). The anchors ^ and $ refer to beginning and end of the string, not the line (unless you specify /m)
Bill
Comment on Re: search a string in a non-regular file