$re = '/(?:^| )(?:(?:https:\/\/)?(?:www\.)?github\.com\/(?<org>[^ \/\n]+)\/(?<repo>[^ \/\n]+)\/issues\/(?<number>[0-9]+)(?:\/)?)(?: |$)/m';
$str = 'ASDFASDF
asdfasdfASdf
asdf
asdf
asdfasdf https://github.com/zeebe-io/backport-action/issues asdf github.com/zeebe-io/backport-action/issues/30 asdf
asdfasdf www.github.com/zeebe-io/
backport-action/issues/30 asdf
asdfasdf www.github.com/zeebe-io/backport-action/issues/30asdf
asdfasdfwww.github.com/zeebe-io/backport-action/issues/30 asdf
asdfasdfwww.github.com/zeebe-io/backport-action/issues/30asdf
asdfsdf https://www.github.com/zeebe-io/backport-action/issues/30 asdfasdfasdf
sadhkasjh https://github.com/zeebe-io/backport-action/issues/30/ asdjfkghasdf
sadfasdf asdf asdfsdf #123 asdfasf#123 sad
sadfasdf asdf asdfsdf zeebe-io/zeebe#123 asdfasf#123 sad
sadfasdf asdf asdfsdf #sdafsdf asdfasf#123 sadf #442
#123 asdasdasd
sadfasdf asdf asdfsdf #123 asdfasf#123 sad
sadfasdf asdf asdfsdf #123asdfasf#123 sad
sadfasdf asdf asdfsdf#123 asdfasf#123 sad
adasdasdasd #123
zeebe-io/zeebe#123 asdfas
sadfasdf asdf asdfsdf zeebe-io/
zeebe#123 asdfasf#123 sad
sadfasdf asdf asdfsdf zeebe-io/zeebe#123 asdfasf#123 sad
sadfasdf asdf asdfsdf zeebe-io/zeebe#123asdfasf#123 sad
sadfasdf asdf asdfsdf/zeebe-io/zeebe#123 asdfasf#123 sad
asdasfasf zeebe-io/zeebe#123
#123
closes#234asdfasdf
resolves #123123123123
#234
Bye bye';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php