---
title: "plocka ut"
type: "forum-thread"
url: "https://www.webforum.nu/amne/php/123434-plocka-ut"
topic: "PHP"
topic_url: "https://www.webforum.nu/amne/php"
author: "pellesvenne"
published: "2005-03-01T00:05:40.000Z"
updated: "2005-03-01T17:35:40.000Z"
replies: 2
views: 258
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/123434-plocka-ut"
---

# plocka ut

## #1 — pellesvenne, 2005-03-01T00:05Z

hur gör jag för att plocka ut **hejsan**!

function test($text) {
$text = preg_replace ("'\<b\>(\*.?)\</b\>'i", "$1", $text );
return $text;
}

echo test("gg\<b\>hejsan\</b\>kkkkk");

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

## #2 — jOOOL, 2005-03-01T15:19Z

först och främst (.\*?)  ska det vara \_inte\_ (\*.?)
sedan måste du escapepa $1 så här \\$1 .
Funktionen bör altså vara så här:

\###########

function test($text) {
$text = preg_replace ("'\<b\>(.\*?)\</b\>'i", "\\$1", $text );
return $text;
}

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

## #3 — Peeer, 2005-03-01T17:35Z

```php
function test($text) {
	preg_match("'<b>(.*?)</b>'is",$text,$text);
	$text = $text[1];
	return $text;
}

echo test("gg<b>hejsan</b>kkkkk");
```

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

---

Tråden på webben: https://www.webforum.nu/amne/php/123434-plocka-ut
