How to call a function in regex_replace with matches? I'd like to use some processing function instead of replacement text in regex_replace function. Is there possible to use a function with matches as arguments, like:
SELECT REGEXP_REPLACE( description, '\[([is]?:?)(\d+)\]', CONCAT_WS(' ', \1, \2), 'gi' ) 
  FROM some_table
  WHERE id = 123;

Of course, backreferences \1 and \2 do not work here, but is there some way to use variables instead of them?
Background: description may contain more than one string with a pattern like [12345] or [i:12345] or [s:12345] and I'd like to process such matches into advanced strings, so I thought the best way is to write a custom function and call it with matches of regex_replace. I just did not found in the docs, how could I use matches as variable/arguments. Is this possible or what is a better way to accomplish my goal?
EDIT I show description field before and after:
Lorem ipsum dolor sit amet [123], consectetur adipiscing elit, 
sed do eiusmod tempor incididunt ut labore et [234] magna aliqua.

should be after replacements like:
Lorem ipsum dolor sit amet &quot;one-two-three&quot;, consectetur adipiscing elit, 
sed do eiusmod tempor incididunt ut labore et &quot;two-three-four&quot; magna aliqua.
Use regexp_matches.  The output of capturing parentheses will be stuffed into an array slot and can be accessed from there. Each match of the entire pattern will generate one row, which you could re-aggregate if you wanted to.
SELECT concat_ws(' ',regexp_matches[1],regexp_matches[2]) 
   from regexp_matches( 'foobar[i:89]asdfasdf[s:12]llll[i:9]', 
                        '\[([is]?:?)(\d+)\]',
                        'gi'
                      );