lecichy wrote:
And another simple question, maybe its the same answer.
whats the syntax of eregi_replace?
You better switch to preg_ functions. They're faster and more powerful
than ereg*
if I want to match ( remove in this case ) few strings, not one:
eregi_replace (("stringone" && "stringtwo"), "", $source)
Try
<?php
$destin = preg_replace('/string(?:one|two)/i', '', $source)
?>
/string(?:one|two)/i -- means:
/ # start of regex
string # match "string literally"
(?: # start a group but don't grab (no need for that)
one # literal "one"
| # OR
two # literal "two"
) # end group
/i # end regex, but match without regard to case
see the preg_ function at
http://pt.php.net/manual/en/ref.pcre.php
Also try regex-coach from http://weitz.de/regex-coach/
using the PCRE_EXTENDED modifier (x) you can put the regex and
the comments in the source file
<?php
function AHREF2text($string) {
return preg_replace(
'@ # start of regex
<a[ ] # literal "<a " (notice the space)
[^<]* # any number of (any characters EXCEPT "<")
href= # literal "href="
("|\')? # optional double OR single quote (grabbed)
([^"\']*) # any number of (anything BUT double
## OR single quote) (grabbed)
("|\')? # optional double OR single quote (grabbed)
[^>]* # any number of (any characters EXCEPT ">") # a literal ">"
([^<]*) # any number of anything BUT "<" (grabbed)
</a> # literal "</a>"
@ix', # end regex, caseless and extended
'[\\4] (link: \\2)', $string);
}
// =============================
$x = 'At <a href="http://mysite.example.com/">my site</a> there
are many <a href="http://examples.example.com/">examples</a> :)';
echo $x, '<hr />', htmlentities($x), '<hr />', AHREF2text($x);
?>
--
I have a spam filter working.
To mail me include "urkxvq" (with or without the quotes)
in the subject line, or your mail will be ruthlessly discarded.