I am pretty new to the use of preg_match. Searched a lot for an answer before posting this question. Found a lot of posts to get data based on youtube ID etc. But nothing as
You can try this:
preg_match('~(?<=\[#)\d+(?=])~', $txt, $match);
(?<=..) is a lookbehind (only a check)
(?<=..)
(?=..) is a lookahead
(?=..)