Postgresql - How do I extract the first occurence of a substring in a string using a regular expression pattern?
<p>I am trying to extract a substring from a text column using a regular expression, but in some cases, there are multiple instances of that substring in the string. </p>

<p>In those cases, I am finding that the query does not return the first occurrence of the substring. Does anyone know what I am doing wrong? </p>

<p>For example:</p>

<p>If I have this data:</p>

<pre><code>create table data1
(full_text text, name text);

insert into data1 (full_text)
values ('I 56, donkey, moon, I 92')
</code></pre>

<p>I am using </p>

<pre><code>UPDATE data1
SET name = substring(full_text from '%#"I ([0-9]{1,3})#"%' for '#')
</code></pre>

<p>and I want to get <code>'I 56'</code> not <code>'I 92'</code></p>