Can I extract the string aaa
without using subpatterns (but still using regexp)?
$str = 'abc#aaa#abc';
preg_match('/#(.*)#/', $str, $matches);
print_r($matches);
Update
I'm just trying to figure out some regexp alternatives !
/(?<=#).*?(?=#)/
But why wouldn't you want to use a capturing group?
Alternative to look-ahead / look-behind assertions:
echo preg_replace('/^.*?#|#.*?$/s', '', 'abc#aaa#abc');