PHP/String/ereg replace
Содержание
back-reference parenthesized substrings
<?
$url = "wbex (http://www.wbex.ru)";
$url = ereg_replace("http://(([A�Za�z0�9.\-])*)", "<a href=\"\\0\">\\0</a>",$url);
print $url;
?>
ereg_replace
<?
$inmystring = "Hello World!";
$mynewstring = ereg_replace("Hello", "Goodbye", $inmystring);
print $mynewstring;
?>
ereg_replace-2
<?php
$url = "wbex (http://www.wbex.ru)";
$url = ereg_replace("http://([a-zA-Z0-9./-]+)([a-zA-Z/]+)", "<a href=\"\\0\">\\0</a>", $url);
print $url;
?>
ereg_replace() function searches for string and replaces pattern if found.
The syntax is: string ereg_replace (string pattern, string replacement, string string)
<?
$copy_date = "Copyright 2009";
$copy_date = ereg_replace("([0?9]+)", "2010", $copy_date);
print $copy_date;
?>
ereg_replace.php
<?php
$text = "http://www.wbex.ru/.";
echo ereg_replace("http://([a-zA-Z0-9./-]+)$", "<a href=\"\\0\">\\0</a>", $text);
?>
Using ereg_replace
<?php
$s = "m@t.ca";
echo ereg_replace ("([[:alpha:]]+)@([[:alpha:]]+)\.([[:alpha:]]{2,4})",
"\1 at \2 dot \3", $s)
?>