***HELP: Me crazy or PHP stuffed? (ereg_replace)
| From: | Tyson Lloyd Thwaites | Date: | Fri, 15 Sep 2000 02:21:26 +0000 |
| Subject: | ***HELP: Me crazy or PHP stuffed? (ereg_replace) | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-2897@lists.php.net to get a copy of this message | ||
Hi guys,
I hope this is the right forum for this, but...
I am trying to write a PowerDynamo to PHP convertor (I know, I know) and I
am
having some troubles with regular expressions.
What I am trying to do is seperate every 'token' by spaces. So:
a==a;
Would become:
a = = a ;
Then I can split the file into an array and parse it. The problem is, I need
to keep
compound operators intact, so:
a==a;
Would become:
a == a ;
I can do the above quite easily with ereg_replace("==", " == ", $line);
The problem arises when I try to then go through and seperate all the
*single '=' signs. If I use ereg_replace("=", " = ", $line), I get:
a = = a ;
BUT then if I go ereg_replace("= =", " == ", $line); I get no joy.
I tried "\= \=", "=[ ]=", "=\s=", but nothing happens.
The curious thing is, if I do ereg_replace("else if", "elseif", $line);
it does that fine. So what's wrong with replacing '=' signs? Are they
meta characters? Is ereg_replace broken?
Thanks for any help.
Regards,
Tyson Lloyd Thwaites
IT&e Ltd