---
title: "tag replace"
type: "forum-thread"
url: "https://www.webforum.nu/amne/php/118816-tag-replace"
topic: "PHP"
topic_url: "https://www.webforum.nu/amne/php"
author: "WiZzLeR"
published: "2004-12-28T13:19:11.000Z"
updated: "2004-12-28T13:48:18.000Z"
replies: 1
views: 236
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/php/118816-tag-replace"
---

# tag replace

## #1 — WiZzLeR, 2004-12-28T13:19Z

här kommer min svaga sida:

```php
$string = preg_replace( "/\[IMG\](.+?)\[\/IMG]/Uis", "<img src='\\1'>", $string);
```

varför fungerar inte det här när man har två IMG-taggar direkt efter varandra?

outputen blir så här: 

```php
<img src='image1.jpg[/IMG][IMG]image2.jpg'>
```

när jag skriver:

```php
[IMG]image1.jpg[/IMG][IMG]image2.jpg[/IMG]
```

Permalänk: https://www.webforum.nu/p/118816

## #2 — Peter S, 2004-12-28T13:48Z

```php
preg_replace( "/\\[IMG\\](.+?)\\[\\/IMG\\]/is", "<img src='\\1'>", $string);
```

 :)

Permalänk: https://www.webforum.nu/p/1515142

---

Tråden på webben: https://www.webforum.nu/amne/php/118816-tag-replace
