I'm working on a project that translates source code from one language to another (something I picked up again after four years this weekend.) I'm rewriting and finishing the entire program in PHP with a better syntax and better translation algorithm. There's one kink I've not been able to find my way around... replacing tokenized words with other tokenization methods... for instance:
In this very simple and confined example, the input string has a PHP variable syntax... I need to change the PHP variables to QB strings for instance... so I want the dollar sign moved from the left to the right of the variable name. For this, I use ereg_replace...
$string = 'set $blah = function($value)';
$string = ereg_replace("(\\$)([a-zA-Z0-9._-])*","\\0$",$string).'<br>';
echo $string;
Outputs: set $blah$ = function($value$)
and it needs to output: set blah$ = function(value$)
Unfortunately, I have limited knowledge of regular expressions, and especially the ereg_replace function in PHP.
This is a very small part of the engine (the options of the variable's template flag,) but very important for doing things like reformatting variable types and such. Is there anyone who knows how to properly put together the regular expression so that it gets rid of the leading "$"?
Please help, there's not much documentation about this function that's useful in this case.
Thanks,
~Tax