It's nothing that I am with this regular expressions stuff. I don't get the regular expression for my requirement. Here is the string format that I have to split with a regular expression in PHP.
ABCxxxx_ABCDEfghi_YYYYmmddhhmmss.mp4
In this string,
ABC -word(case sensitive)
x -any digit
ABCDEfghi -word(case sensitive)
YYYYmmddhhmmss -timestamp value
.mp4 -word preceded with a dot(.)
All I need is to extract the date from this string.
ie, take YYYYmmdd to a variable.
I know that this is not the way of writing it, but I tried. Here is the attempt:
$s = "ABC0000_ABCDEfghi_20000101223344.mp4";
$regex = "/\ABC[0-9]{4}_ABCDEfghi_&var=[0-9]{8}[0-9]{6}+\.mp4/";
$matches = array();
$s = preg_match($regex, $s, $matches);
print_r($matches[1]);
THE ERROR:
( ! ) Notice: Undefined offset: 1 in D:\wamp\www\Test\regex.php on line 6 Call Stack Time Memory Function Location 1 0.0000 241296 {main}( ) ..\regex.php:0
I am stuck. Please help me with a solution.