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
Regex-get integer between tags
Moderator: General Moderators
- rupam_jaiswal
- Forum Newbie
- Posts: 22
- Joined: Thu Jun 05, 2008 12:54 am
Re: Regex-get integer between tags
Code: Select all
<?php
$subject = "[ABCDEF]123[/ABCDEF]";
$pattern = '#\[ABCDEF\](\d+)\[/ABCDEF\]#';
preg_match($pattern, $subject, $matches);
print_r($matches);
?>