🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.php
Article #1241

Re: Zamiana z ereg_replace

#1241
From: Filipus
Date: Mon, 27 Aug 2001 10:35
21 lines
1464 bytes
Cześć

> Chcę zamienić znak '+' na '%2b' poprzez ereg_replace,
> ale po zwykłym wywołaniu czyli:
> $tekst = ereg_replace("+","%2b",$tekst);
> 
> otrzymuję komunikat:
> Warning: REG_BADRPT: in ... on line 41

ereg_replace operuje na wyrażeniach regularnych. 
+ ma w w nich specjalne znaczenie, podobnie jak .()[]|*^$ 
żeby użyć go (i innych znaków specjalnych) jako normalnego znaku, 
który ma się pojawić w tekscie, poprzedź go backslash'em:

$tekst = ereg_replace("\+","%2b",$tekst);

[polecam gdzieś poczytać więcej o wyrażeniach regularnych, 
nie są zbyt trudne, a mają duuuże możliwości].

pozdrawiam
Filipus
Technical Details
Message-ID: <3B8A225A.7B833938@nospam.rpg.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!mat.uni.torun.pl!news.man.torun.pl!news.icm.edu.pl!newsfeed.tpinternet.pl!news.tpi.pl!not-for-mail
References: <4238.00000000.3b8a1bc6@newsgate.onet.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!mat.uni.torun.pl!news.man.torun.pl!news.icm.edu.pl!newsfeed.tpinternet.pl!news.tpi.pl!not-for-mail
From: Filipus <filipus@nospam.rpg.pl>
Newsgroups: pl.comp.lang.php
Subject: Re: Zamiana z ereg_replace
Date: Mon, 27 Aug 2001 12:35:06 +0200
Organization: tp.internet - http://www.tpi.pl
Lines: 21
Message-ID: <3B8A225A.7B833938@nospam.rpg.pl>
References: <4238.00000000.3b8a1bc6@newsgate.onet.pl>
NNTP-Posting-Host: 195.117.143.124
Mime-Version: 1.0
X-Trace: news.tpi.pl 998908489 29688 195.117.143.124 (27 Aug 2001 10:34:49 GMT)
X-Complaints-To: usenet@tpi.pl
NNTP-Posting-Date: 27 Aug 2001 10:34:49 GMT
X-Accept-Language: en
X-Mailer: Mozilla 4.7 [en] (WinNT; I)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit