rupam_jaiswal Posted January 11, 2010 Share Posted January 11, 2010 Hi, Please excuse if similar issue has been posted earlier. My data is like I am going [ABCDEF]123[/ABCDEF] to movie. I want a regex to get the value between [ABCDEF] and [/ABCDEF] only if its integer. eg if its [ABCDEF]junk characters[/ABCDEF] then I dont want...but if its [ABCDEF]123[/ABCDEF] then I require 123 Regards Quote Link to comment https://forums.phpfreaks.com/topic/188020-regex-get-integer-between-tags/ Share on other sites More sharing options...
thebadbad Posted January 11, 2010 Share Posted January 11, 2010 <?php $str = 'I am going [ABCDEF]123[/ABCDEF] to movie.'; preg_match_all('~\[ABCDEF\]([0-9]+)\[/ABCDEF\]~', $str, $matches); echo '<pre>' . print_r($matches[1], true) . '</pre>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/188020-regex-get-integer-between-tags/#findComment-992677 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.