phpbar.de logo

Mailinglisten-Archive

[php] Re: Nochmal was mit regulaeren Ausdruecken

[php] Re: Nochmal was mit regulaeren Ausdruecken

Kristian =?iso-8859-1?Q?K=F6hntopp?= kk_(at)_netuse.de
Mon, 06 Sep 1999 15:19:20 +0200


Martin Ramsch wrote:
>     /* Discard unwanted parts */
>     $contents = eregi_replace('^.*<BODY[^>]*>', '', $contents);
>     $contents = eregi_replace('</BODY>.*$', '', $contents);

Und weil es so schön ist, kann man das mit preg_replace() das
ganze und noch viel mehr (etwa Template-Ersetzung) auch in
einem Aufwasch machen.

kk_(at)_land:~ > Source/php3/php
<?php
  $str = "<html>hahaha<body lalala>trulla</body>gurps";

  $old = array("=^.*<body.*?>=i", "=</body>.*$=i");
  $new = array("", "");
  $res = preg_replace($old, $new, $str);
  print $res;
Content-type: text/html

trulla

Außerdem sind Perl Regexp sowieso viel toller, und Posix ist doof.

Kristian

-- 
Kristian Köhntopp, NetUSE Kommunikationstechnologie GmbH
Siemenswall, D-24107 Kiel, Germany, +49 431 386 436 00
Using PHP3? See our web development library at
http://phplib.shonline.de/ (GPL)


php::bar PHP Wiki   -   Listenarchive