I have a string like this:
01.jpg"> 01]02.jpg"> 02]03.jpg"> 03]04.jpg"> 04]05.jpg"> 05]06.jpg"> 06]07.jpg"> 07]08.jpg"> 08]09.jpg"> 09]10.jpg"> 10]11.jpg"> 11]12.jpg"> 12]13.jpg"> 13]14.jpg"> 14]15.jpg"> 15]16.jpg"> 16]17.jpg"> 17]18-19.jpg"> 18-19]20.jpg"> 20
As a result I want to only have:
01.jpg#02.jpg#03.jpg#04.jpg ... until 20.jpg
So I need to replace "> (.*)]
by #
How can I accomplish this?
You have an almost working pattern to use with preg_replace()
. Try this:
$string = preg_replace('/"> \d+\]?/', '#', $string);
\d+
is digit one or more times]
needs to be escaped with \
?
makes the ]
optionalAn alternate pattern would be /"> [^\]]+\]?/
.