Hi;
I need to grab any the format ten numbers then a dot then jpg or png inside the {image}{/image} tag, for example :
1. {image}1390324469.jpg{/image} should return 1390324469.jpg without spaces
2. {image} 1390324469.jpg {/image} should return 1390324469.jpg without spaces
3. {image}unicode or non numbners characters1390324469.jpgunicode or non numbers characters{/image} should return 1390324469.jpg without spaces
This one "#{image}(.*?){\/image}#i", does only work in the first case and doesn't work in the second and third cases.
Thank you.
Regex help
Moderator: General Moderators
Re: Regex help
Code: Select all
php > $haystack = '{image}abcdefg1390324469.jpgabcdefg{/image}';
php > preg_match('/\{image\}.*?(\d{10}\.(jpg|png)).*?\{\/image\}/', $haystack, $matches);
php > print_r($matches);
Array
(
[0] => {image}abcdefg1390324469.jpgabcdefg{/image}
[1] => 1390324469.jpg
[2] => jpg
)
php >Re: Regex help
Quick and wright answer, this one work,
"#{image}.*?(\d{10}\.(jpg|png)).*?{\/image}#i"
Thank you
"#{image}.*?(\d{10}\.(jpg|png)).*?{\/image}#i"
Thank you