A slightly different approach can give you what you are looking for. By using a lookahead, you can do what you want.
$term = 'Dit is het eerste het is niet het laatste Dit';
@captured = $term =~ /\b(\w\w\w)\b(?=.*\1\b)/g;
print join ' ', @captured;
_____________
Dit het het
The \b are word boudaries (change from letter/number/underscore) to non-letter/number/underscore or vice-versa.
The (?= looks forward for what comes after it, but remembers where it starts.
The \1 is the same as your \g1 (I unfortunately have an older perl.)
The g at the end means capture them all
het appears twice since it is there three times
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|