sasha
07-27-2006, 07:25 PM
Hello I am looking for JavaScript equivalent of this:
$this->TokenSymbol = '%';
$this->ItemTokens = array ('TEST' => 'some value' , 'TEST2'=>'some other value' ) ;
$inString = 'This is some %NOT_USED% , %TEST% la la 'TEST2' ;
$outString = preg_replace ("/".$this->TokenSymbol."(\w+)".$this->TokenSymbol."/e" , "\$this->ItemTokens['\\1']" , $inString ) ;
echo $outString ;
$inString could be very large variable and this could be executed many times in the same page so it should be very efficient (entire input should be parsed in single pass)
Any help/pointers are welcome
$this->TokenSymbol = '%';
$this->ItemTokens = array ('TEST' => 'some value' , 'TEST2'=>'some other value' ) ;
$inString = 'This is some %NOT_USED% , %TEST% la la 'TEST2' ;
$outString = preg_replace ("/".$this->TokenSymbol."(\w+)".$this->TokenSymbol."/e" , "\$this->ItemTokens['\\1']" , $inString ) ;
echo $outString ;
$inString could be very large variable and this could be executed many times in the same page so it should be very efficient (entire input should be parsed in single pass)
Any help/pointers are welcome
