Tony
Tony

Reputation: 333

Remove everything between two strings

Need to remove everything between .jpg and > on all instances like these below:

So everything becomes .jpg>

Any suggestions using preg_replace?

Upvotes: 1

Views: 1618

Answers (2)

subroutines
subroutines

Reputation: 1458

preg_replace('/\.jpg[^>]+>/', '.jpg>', $your_string);

Upvotes: 1

tuchk4
tuchk4

Reputation: 2350

$str = '.jpg|500|756|20121231-just-some-image-3.jpg)%>';
preg_replace('/[^\.jpg][^>]+/', '', $str);

Upvotes: 0

Related Questions