Well actually not a real lot so far. I'm just trial and error(lots of that)
at the moment. I've only been 'playing with php for about a month or so.
$file = "phptest1.txt";
$rep = array ("tbl_" , "_%", "bool default 0", "bool default 1", '?');
$wih = array ("", "_pc", "bool DEFAULT FALSE", "bool DEFAULT TRUE", "" );
if (is_file($file)) :
$fh = fopen($file, "r+") or die("File does not exist");
while (! feof($fh)) :
$line = fgets($fh,4096);
$str = strtolower($line);
$str_fixed = str_replace($rep, $wih, $str);
print $str_fixed . "<br />";
endwhile;
Then as far as the regexp part for replacing the space inbetween [blah blah
blah] with _ goes it was a case of try delete try delete etc. I may need to
break the string into an array but that in its self adds its own problems.
Think one of my problems is Im try to run before I can crawl with php,
postgre regex etc. Also its fun trying to workout things when all the books
you come across are php/mysql.
Came across an old message in my trawl of the news group that 'may' help
going to give that a try as soon as I get the time. (it was more to do with
replacing | with space between " " but it maybe convertable)
"Keith Roberts" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Can yo upost the code you have got to do the conversion so far please?
>
> Regards
>
> Keith
>
> -----------------------------------------------------------------
> Websites:
> http://www.karsites.net
> http://www.php-debuggers.net
> http://www.raised-from-the-dead.org.uk
>
> All email addresses are challenge-response protected with
> TMDA [http://tmda.net]
> -----------------------------------------------------------------
>
> On Mon, 21 Jan 2008, Peter wrote:
>
>> To: [email protected]
>> From: Peter <[EMAIL PROTECTED]>
>> Subject: [PHP] regex
>>
>> I am trying to convert ms access sql to postgresql using php.
>>
>> I have a sql statement in the form ;-
>> $sql = SELECT DISTINCT [Table Name].[Column.Name], [Table Name 1].[Column
>> Name 2] etc.
>>
>> what I want to end up with is $sql = SELECT DISTINCT
>> table_name.column_name,
>> table_name_1.column_name_2, ........
>>
>> I have managed to get the caps to lower but I cant work out how to put
>> the _
>> in place of spaces if the spaces are between [ ]. I either end up with
>> S_E_L_E_C ..... or SELECT_DISTINCT_ etc... .
>>
>> Naturally I have only used part of sql statement and table, column names
>> have been changed. (Think the one I'm trying on is 2000+ characters. So
>> its
>> not a case of set number of words/numbers between [] it could be 2 or it
>> could be 4 etc)
>>
>> Anyone workout what I am talking about and can help would be appreciated.
>>
>> Peter
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php