liamthebof Posted August 22, 2008 Share Posted August 22, 2008 The_egg_man</h3><pre>27676 Thats the input string. I want the number, knowing that the length and value of the 'The_egg_man' can change and so can the number. I have tried using preg_match with (\d+) and ([0-9]+) with no avail though no doubt I'm doing it wrong. Any help appreciated, thanks. Link to comment https://forums.phpfreaks.com/topic/120889-solved-is-this-a-regex-job/ Share on other sites More sharing options...
CaptainChainsaw Posted August 22, 2008 Share Posted August 22, 2008 http://www.php.net/strlen Link to comment https://forums.phpfreaks.com/topic/120889-solved-is-this-a-regex-job/#findComment-623123 Share on other sites More sharing options...
liamthebof Posted August 22, 2008 Author Share Posted August 22, 2008 The length of the number may change Link to comment https://forums.phpfreaks.com/topic/120889-solved-is-this-a-regex-job/#findComment-623129 Share on other sites More sharing options...
Demonic Posted August 22, 2008 Share Posted August 22, 2008 Show your code. Link to comment https://forums.phpfreaks.com/topic/120889-solved-is-this-a-regex-job/#findComment-623131 Share on other sites More sharing options...
effigy Posted August 22, 2008 Share Posted August 22, 2008 <pre> <?php $str = 'The_egg_man</h3><pre>27676'; preg_match('%(?<=</h3><pre>)\d+%', $str, $matches); print_r($matches); ?> </pre> Link to comment https://forums.phpfreaks.com/topic/120889-solved-is-this-a-regex-job/#findComment-623134 Share on other sites More sharing options...
liamthebof Posted August 22, 2008 Author Share Posted August 22, 2008 Effigy, worked perfect, Thankyou. Link to comment https://forums.phpfreaks.com/topic/120889-solved-is-this-a-regex-job/#findComment-623139 Share on other sites More sharing options...
.josh Posted August 22, 2008 Share Posted August 22, 2008 you can do like $data = "The_egg_man</h3><pre>27676"; $t = explode ("<pre>", $data); echo $t[1]; or $t = substr(stristr($data,"<pre>"), 5); echo $t; Link to comment https://forums.phpfreaks.com/topic/120889-solved-is-this-a-regex-job/#findComment-623141 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.