in reply to Re^3: get n lines before or after a pattern
in thread get n lines before or after a pattern

Flip that coin. It's not a question of searching for "jackhammer." It's a matter of what *jack* elements could be present in the data (whose contents are, at least possibly, unknown at the time you start writing the code)... as, for example, jackson (mississippi) or jackson hole, colorado.

But note: my reply is directed, not to you, but to the parent of your node... and, thus, casts no aspersions on your prior remark; in fact, it appears to say pretty much the same thing, but you said it first

  • Comment on Re^4: get n lines before or after a pattern

Replies are listed 'Best First'.
Re^5: get n lines before or after a pattern
by Kenosis (Priest) on Jul 25, 2012 at 22:31 UTC

    I do understand your point. However, the OP appears to be only interested in an exact first name match, given the data set and specific example output. Additionally, the OP says, "...I want to search for a particular first name..." (emphasis mine); sub-string matching does not return a particular first name. Based on these factors, it made sense to force an exact first name match--as the OP's desired output showed. It's certainly easy enough, however, to remove the regex's \bs if my exact-match assumption is incorrect.

    Thanks for addressing this issue...