Create output in Array list
<p>An example of my input is:</p>

<pre><code>3-&gt;0 0-&gt;1 1-&gt;2 2-&gt;3
</code></pre>

<p>I need to produce output in an array list </p>

<pre><code>{3,0,1,2}
</code></pre>

<p>How can I achieve this?</p>

<p>If you want the numbers located before the "arrows" (<code>-&gt;</code>), here is a solution using <a href="https://docs.python.org/3/library/re.html" rel="nofollow"><code>re</code></a> :</p>

<pre><code>&gt;&gt;&gt; list(map(int, re.findall('[0-9](?=-&gt;)', '3-&gt;0 0-&gt;1 1-&gt;2 2-&gt;3')))
[3, 0, 1, 2]
</code></pre>

<p>I'm using <a href="https://docs.python.org/3/library/functions.html#map" rel="nofollow"><code>map</code></a> to convert the strings to int.</p>

<p><strong>More informations on the regex used :</strong></p>

<p>I'm using a lookahead expression (<code>(?=-&gt;</code>)) to match only something located before this string : <code>'-&gt;'</code>.
And what I am looking for is a number between 0 and 9, thanks to the set of characters <code>[0-9]</code>.</p>

<p>Please note that this won't match <code>10</code> for example. In this case, I need to change the regex to the following : <code>[0-9]+(?=-&gt;)</code>, to match 1 or more numbers.</p>

python