preg_replace help
- From: "heath" <guyemup@xxxxxxxxx>
- Date: 5 Oct 2005 14:47:52 -0700
are conditional subpatterns not allowed in the replacement string of
preg_replace()? i don't see it in the docs anywhere but my regex is
not giving me what i thought it should:
function pluralize( $singular )
{
$pattern = "/^(\w+)(?:([^aeiou])y|(x|s|z|sh|ch|[^aeiou]o))$/";
$replacement = "\\1(?(2)\\2ies|\\3es)";
echo preg_replace( $pattern, $replacement, $singular, 1 );
}
this outputs the conditional syntax literally. is it just not allowed
or am i missing something syntactically? thanks!
heath
.
- Prev by Date: output buffering problem
- Next by Date: help with preg_replace()
- Previous by thread: output buffering problem
- Next by thread: help with preg_replace()
- Index(es):