Regex
Posted: Tue Feb 17, 2009 8:21 am
Hello, i'm at my wits end with this piece of code.
I'm rewriting my template engine to deal with multiple parts of an if statement, eg:
I have a preg_replace_callback function that works fine, it gets the
part out of the statement.
Only problem now is that whenever I do a regex statement, match or replace, it only captures the first letter after the dollar sign:
yields:
What i'm trying to do is get it into the form of:
with this code:
Instead what comes out is:
Is there something stupid i'm doing?
Cheers,
Darkzaelus
I'm rewriting my template engine to deal with multiple parts of an if statement, eg:
Code: Select all
{if $login_disabled&&$login_disabled}Code: Select all
$login_disabled&&$login_disabledOnly problem now is that whenever I do a regex statement, match or replace, it only captures the first letter after the dollar sign:
Code: Select all
preg_match('/\\$([a-z0-9]+?)/is', $matches[1], $match);
Code: Select all
Array
(
[0] => $l
[1] => l
)
Code: Select all
<?php if($this->PV_vars['login_disabled']): ?>
Code: Select all
preg_replace('/\\$([a-z0-9]+?)/is', '\$this->PV_vars(\'$1\')', $matches[1]);
Code: Select all
<?php if(!$this->PV_vars('l')ogin_disabled): ?>
Cheers,
Darkzaelus