php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #6046 preg_replace for a special pattern
Submitted: 2000-08-09 07:41 UTC Modified: 2001-01-21 03:18 UTC
From: wico at cnh dot nl Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0 Latest CVS (09/08/2000) OS: linux
Private report: No CVE-ID: None
 [2000-08-09 07:41 UTC] wico at cnh dot nl
hiya

if you have a regex that captures more than one pattern i'd to give a argument to the function which to replace

say:
regex: (a)(b)(a)
replace: test

preg_replace("'(a)(b)(a)'", "test", "abaabaaba");
normal preg_replace will replace 'aba' with 'test' outputing: testtesttest

preg_replace_pattern_no("'(a)(b)(a)'", "test", "abaabaaba", 2);
replacing pattern 2 and outputting: atestaatestaatesta

Greetz,

Wico

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-01-21 03:18 UTC] cynic@php.net
use non-capturing patterns.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 16:01:28 2024 UTC