Pass current post title to a predefined link

Looks like it’s possible to use a placeholder tag, the following is the PHP code using a _custom_link value of http://somelink.com/?ref=%%title%%.

<?php
// must be within the Loop
$ref_slug = strtoupper(sanitize_title_with_dashes(get_the_title()));
$regex = '(\%\%title\%\%)';
$ref_link = ( get_option('_custom_link') ) ? preg_replace( $regex, $ref_slug, get_option('_custom_link')) : null;
echo $ref_link;
?>