$text = 'something here *ls67 another thing'; // match
$text2 = 'something here *ls67. another thing'; // match
$text3 = 'something here another thing *ls67.'; // match
$text3 = 'something here another thing *ls67'; // doesn't match (and i need to match this)
$pattern = '|^(.*)?(\*[0-9a-zA-Z_-]{3,15})([^0-9a-zA-Z_-])+(.*)?$|i';
I've tried this pattern but it generates an error:
$pattern = '|^(.*)?(\*[0-9a-zA-Z_-]{3,15})([^0-9a-zA-Z_-]|$)+(.*)?$|i'; // Unknown modifier '$'
// and
$pattern = '|^(.*)?(\*[0-9a-zA-Z_-]{3,15})(([^0-9a-zA-Z_-])+|$)(.*)?$|i'; // same error