Php Regex: Nasıl konunun sonunda ise bir submatch isteğe yapmak için

0 Cevap php
$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';

Ben bu modeli denedim ama bir hata oluşturur:

$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

0 Cevap