Hello,
I am trying to make a comment line reader that reads the value between a sort of syntax.
However it has an space at the end and ofc I could use the trim functions but wondering if its possible within regular expressions.
I thought something like this:Code:<?PHP $var = '--- lol lol ---'; $count = preg_match_all('~---(?:[[:space:]])?(.*)[^[:space:]]$(?:[[:space:]])?---~',$var,$reg); var_dump($reg); ?> array 0 => array 0 => string '--- lol lol ---' (length=15) 1 => array 0 => string 'lol lol ' (length=8)
~---(?:[[:space:]])?(.*)[^[:space:]]$(?:[[:space:]])?---~
(.*)[^[:space:]]$ <- doesn't work
But it doesn't work.
Any suggestions / something to add?
Thanks in advance




Reply With Quote