Finding all matches of string, and also returning line number of match
<p>I have a string variable which contains some text (shown below).  The text has line breaks in it as shown.  I would like to search the text for a given string, and return the number of matches per line number.  For instance, searching for "keyword" would return 1 match on line 3 and 2 matches on line 5.</p>

<p>I have tried using strstr(). It does a good job finding the first match, and giving me the remaining text, so I can do it again and again until there are no matches.  Problem is I do not know how to determine which line number the match occurred on.</p>

<pre><code>Hello,
This is some text.
And a keyword.
Some more text.
Another keyword! And another keyword.
Goodby.
</code></pre>
