Replace throwing Unknown Modifier Error
You'll need to double escape those backslashes in the regex.

  {% set ig = user.instagram|raw|replace('/(?:(?:http|https):\\/\\/)?(?:www.)?(?:instagram.com|instagr.am)\\/([A-Za-z0-9-_\\.]+)/im') %}