diff --git a/phpbb2drupal_core.inc b/phpbb2drupal_core.inc
index fa49e95..e11894c 100644
--- a/phpbb2drupal_core.inc
+++ b/phpbb2drupal_core.inc
@@ -362,7 +362,7 @@ class PhpbbTopicMigration extends PhpbbMigration {
   function prepareRow($post) {
     // remove the :bbcode_uid from post_text
     if (!empty($post->bbcode_uid)) {
-      $post->post_text = preg_replace("/:$post->bbcode_uid/", '', $post->post_text);
+      $post->post_text = preg_replace("/(:[a-z])?:$post->bbcode_uid\]/", ']', $post->post_text);
     }
     $post->post_text = PhpbbContentHelpers::stripBbcode($post->post_text);
     $post->post_text = PhpbbContentHelpers::textSanitise($post->post_text);
