Find pattern in files with java 8 : <p>consider I have a file like (just an excerpt)</p>

<pre><code>name: 'foobar'
</code></pre>

<p>I like to retrieve <code>foobar</code> when I discover the line with <code>name</code>.</p>

<p>My current approach is</p>

<pre><code>Pattern m = Pattern.compile("name: '(.+)'");
try (Stream&lt;String&gt; lines = Files.lines(ruleFile)) {
    Optional&lt;String&gt; message = lines.filter(m.asPredicate()).findFirst();
    if (message.isPresent()) {
        Matcher matcher = m.matcher(message.get());
        matcher.find();
        String group = matcher.group(1);
        System.out.println(group);
    }
}
</code></pre>

<p>which looks not nice. The excessive use of the pattern and matcher seems wrong.</p>

<p>Is there a easier/better way ? Especially if I have multiple keys I like to search like this ?</p>
