php-general Digest 2 Aug 2004 01:04:38 -0000 Issue 2912

Topics (messages 192434 through 192451):

regex help
        192434 by: Kathleen Ballard
        192435 by: Jim Grill
        192447 by: Justin Patrin
        192448 by: Justin Patrin

Re: php4.3.7 + phpBB 2.0.10 + Apache - zero sized replies with
        192436 by: ADFH
        192450 by: John Nichel

Re: php4.3.7 + phpBB 2.0.10 + Apache - zero sized replies
        192437 by: ADFH

Should I wait for PHP 5.1?
        192438 by: Randall Perry
        192439 by: Matthew Sims
        192444 by: Gerard Samuel

regex help needed
        192440 by: Kathleen Ballard
        192441 by: M. Sokolewicz
        192442 by: Fabrice Lezoray

PHP5 + OpenSSL extension appears to ignore "extension sections" in configarg array
        192443 by: User1001

Cannot compile
        192445 by: Andrew W

Re: regex help needed -- Solved!  Thanks!
        192446 by: Kathleen Ballard

upload changes accented character
        192449 by: Lowell Allen

Upgrade PHP?
        192451 by: Will Collins

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
I am at the tailend of a project that involves moving
legacy data from one dbms to another.  The client has
added a new requirement to the data manipulation that
is required. I need to remove all <br /> tags (there
may be more that one) that appear within all <h*>
tags.  

I am not very familiar with building regular
expressions, but I see this as a 2 part process. 
First, to grab <h*> tags, and second, to strip the
br's. 

I can grab the beginning of the tag easily, but my
expressions grab too much.

Also, I am not sure how to remove the br's.

Any help would be appreciated.  I have tried to find
similar examples, but without any luck.  Also, php5 is
not an option at this point.

Kathleen

--- End Message ---
--- Begin Message ---
Can you post a little sample of the data and your current code?

thanks.

Jim Grill
Web-1 Hosting
http://www.web-1hosting.net

----- Original Message ----- 
From: "Kathleen Ballard" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, August 01, 2004 8:27 AM
Subject: [PHP] regex help


> I am at the tailend of a project that involves moving
> legacy data from one dbms to another.  The client has
> added a new requirement to the data manipulation that
> is required. I need to remove all <br /> tags (there
> may be more that one) that appear within all <h*>
> tags.  
> 
> I am not very familiar with building regular
> expressions, but I see this as a 2 part process. 
> First, to grab <h*> tags, and second, to strip the
> br's. 
> 
> I can grab the beginning of the tag easily, but my
> expressions grab too much.
> 
> Also, I am not sure how to remove the br's.
> 
> Any help would be appreciated.  I have tried to find
> similar examples, but without any luck.  Also, php5 is
> not an option at this point.
> 
> Kathleen
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

--- End Message ---
--- Begin Message ---
On Sun, 1 Aug 2004 06:27:51 -0700 (PDT), Kathleen Ballard
<[EMAIL PROTECTED]> wrote:
> I am at the tailend of a project that involves moving
> legacy data from one dbms to another.  The client has
> added a new requirement to the data manipulation that
> is required. I need to remove all <br /> tags (there
> may be more that one) that appear within all <h*>
> tags.
> 
> I am not very familiar with building regular
> expressions, but I see this as a 2 part process.
> First, to grab <h*> tags, and second, to strip the
> br's.
> 
> I can grab the beginning of the tag easily, but my
> expressions grab too much.
> 
> Also, I am not sure how to remove the br's.
> 
> Any help would be appreciated.  I have tried to find
> similar examples, but without any luck.  Also, php5 is
> not an option at this point.
> 

$text = preg_replace('!(<h\d[^>]*>.*?)<br/>(.*?</h\d>)!is', '\1\2', $text);

You may also have to do this several times as this will only get one
br per <h> tag.

$newText = $text;
do {
  $text = $newText;
  $newText = preg_replace('!(<h\d[^>]*>.*?)<br/>(.*?</h\d>)!is', '\1\2', $text);
} while($text != $newText);

> Kathleen
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

--- End Message ---
--- Begin Message ---
Forget my first attempt, using the e modifier and another preg_replace
is much better.

$return = preg_replace('!<h(\d)>(.*?)</h\1>!ie',
'preg_replace("!<br[^>]*>!i", "", "$1")', $originalText);

On Sun, 1 Aug 2004 13:39:49 -0700, Justin Patrin <[EMAIL PROTECTED]> wrote:
> On Sun, 1 Aug 2004 06:27:51 -0700 (PDT), Kathleen Ballard
> <[EMAIL PROTECTED]> wrote:
> > I am at the tailend of a project that involves moving
> > legacy data from one dbms to another.  The client has
> > added a new requirement to the data manipulation that
> > is required. I need to remove all <br /> tags (there
> > may be more that one) that appear within all <h*>
> > tags.
> >
> > I am not very familiar with building regular
> > expressions, but I see this as a 2 part process.
> > First, to grab <h*> tags, and second, to strip the
> > br's.
> >
> > I can grab the beginning of the tag easily, but my
> > expressions grab too much.
> >
> > Also, I am not sure how to remove the br's.
> >
> > Any help would be appreciated.  I have tried to find
> > similar examples, but without any luck.  Also, php5 is
> > not an option at this point.
> >
> 
> $text = preg_replace('!(<h\d[^>]*>.*?)<br/>(.*?</h\d>)!is', '\1\2', $text);
> 
> You may also have to do this several times as this will only get one
> br per <h> tag.
> 
> $newText = $text;
> do {
>   $text = $newText;
>   $newText = preg_replace('!(<h\d[^>]*>.*?)<br/>(.*?</h\d>)!is', '\1\2', $text);
> } while($text != $newText);
> 
> 
> 
> > Kathleen
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> 
> --
> DB_DataObject_FormBuilder - The database at your fingertips
> http://pear.php.net/package/DB_DataObject_FormBuilder
> 
> paperCrane --Justin Patrin--
> 


-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

--- End Message ---
--- Begin Message ---
> Can you verify that the data is actually in the db?

I'll attempt to reverify by dumping data back out again and comparing
size. I suspect it is, however.

Ie. The login succeeds because a cookie is set, and I can go to some
    scripts, but not others.

Even if it isn't, how could this stop Apache from logging even an error?

> Also, you may want to try importing the dump and not relying on your 
> MySQL configuration file....
> 
> mysql --user=<username> -p dbname < dumpname.sql

Have done this too in initial tests, I just got sick of typing password
all the time :)

--- End Message ---
--- Begin Message ---
ADFH wrote:

Can you verify that the data is actually in the db?


I'll attempt to reverify by dumping data back out again and comparing
size. I suspect it is, however.

Ie. The login succeeds because a cookie is set, and I can go to some
    scripts, but not others.

Even if it isn't, how could this stop Apache from logging even an error?

Why would Apache log an error on a db dump? Or are you talking about the execution of the scripts after you import the data? If the latter try setting your php error reporting to E_ALL in a .htaccess file (or in the php.ini if you have access to that).


For .htaccess :
php_value error_reporting "E_ALL"

If you set it in the php.ini, make sure to restart your web server.

--
By-Tor.com
It's all about the Rush
http://www.by-tor.com

--- End Message ---
--- Begin Message ---
> > Can you verify that the data is actually in the db?
> I'll attempt to reverify by dumping data back out again and comparing
> size. I suspect it is, however.

21M Jul 29 23:19 20040509-clean.sql <-- Before
21M Aug  1 12:03 redump.sql         <-- After

Yeah.. all the data's in the DB.

--- End Message ---
--- Begin Message ---
Any major gotchas going from 4 to 5? Any problems with PostgreSQL
connectivity? Will I have to scour and rewrite current scripts?



-- 
Randall Perry
sysTame

Xserve Web Hosting/Co-location
Website Design/Development
WebObjects Hosting
Mac Consulting/Sales

http://www.systame.com/

--- End Message ---
--- Begin Message ---
> Any major gotchas going from 4 to 5? Any problems with PostgreSQL
> connectivity? Will I have to scour and rewrite current scripts?
>
>
>
> --
> Randall Perry

Suppoedly, all code from PHP4 is backwards compatible with PHP5. I think
the only major re-vamp was its Object Oriented Model.

-- 
--Matthew Sims
--<http://killermookie.org>

--- End Message ---
--- Begin Message ---
On Sunday 01 August 2004 12:19 pm, Randall Perry wrote:
> Any major gotchas going from 4 to 5? Any problems with PostgreSQL
> connectivity? Will I have to scour and rewrite current scripts?
>

My opininon would be to wait on maybe 5.0.1, especially if its on a production 
box.  Im not having an absolute blast with it on my dev boxes...

--- End Message ---
--- Begin Message ---
Sorry,
Here is the code I am using to match the <h*> tags:

<h([1-9]){1}>.*</h([1-9]){1}>

I have removed all the NL and CR chars from the string
I am matching to make things easier.  Also, I have run
tidy on the code so the tags are all uniform.

The above string seems to match the tag well now, but
I still need to remove the br tags from the tag
contents (.*).

The strings I will be matching are html formatted
text.  Sample <h*> tags with content are below:

<h4>Ex-Secretary Mickey Mouse <br />Loses Mass.
Primary</h4>

<h4>Ex-Secretary Mickey Mouse <br />Loses Mass.
Primary <br /> Wins New Jersey</h4>

<h4>Ex-Secretary Reich Loses Mass. Primary</h4>

Again, any help is appreciated.
Kathleen

--- End Message ---
--- Begin Message --- You could try something like:
$return = preg_replace('#<h[1-9]>(.*)</h[1-9]>#Uie', 'str_replace("<br />", "", "$1")');



- Tul

Kathleen Ballard wrote:
Sorry,
Here is the code I am using to match the <h*> tags:

<h([1-9]){1}>.*</h([1-9]){1}>

I have removed all the NL and CR chars from the string
I am matching to make things easier.  Also, I have run
tidy on the code so the tags are all uniform.

The above string seems to match the tag well now, but
I still need to remove the br tags from the tag
contents (.*).

The strings I will be matching are html formatted
text.  Sample <h*> tags with content are below:

<h4>Ex-Secretary Mickey Mouse <br />Loses Mass.
Primary</h4>

<h4>Ex-Secretary Mickey Mouse <br />Loses Mass.
Primary <br /> Wins New Jersey</h4>

<h4>Ex-Secretary Reich Loses Mass. Primary</h4>

Again, any help is appreciated.
Kathleen

--- End Message ---
--- Begin Message ---
hi

M. Sokolewicz a écrit :
You could try something like:
$return = preg_replace('#<h[1-9]>(.*)</h[1-9]>#Uie', 'str_replace("<br />", "", "$1")');



- Tul

Kathleen Ballard wrote:

Sorry,
Here is the code I am using to match the <h*> tags:

<h([1-9]){1}>.*</h([1-9]){1}>
I think this mask is better :
`<h([1-6])>.*?</h\1)>`sie



I have removed all the NL and CR chars from the string I am matching to make things easier. Also, I have run tidy on the code so the tags are all uniform.

The above string seems to match the tag well now, but
I still need to remove the br tags from the tag
contents (.*).
To remove the <br /> tags, you need to call preg_replace_callback() :

<?php
$str = '<h1>hi <br /> ..</h1> bla bla <h5> .... <br /> ..</h5> ...<br />';
function cbk_br($match) {
return '<h' . $match[1] . '>' . str_replace('<br />', '', $match[2]) . '</h' . $match[1] . '>';
}
$return = preg_replace_callback('`<h([1-6])>(.*?)</h\1>`si', 'cbk_br', $str);
echo $return;
?>



The strings I will be matching are html formatted text. Sample <h*> tags with content are below:

<h4>Ex-Secretary Mickey Mouse <br />Loses Mass.
Primary</h4>

<h4>Ex-Secretary Mickey Mouse <br />Loses Mass.
Primary <br /> Wins New Jersey</h4>

<h4>Ex-Secretary Reich Loses Mass. Primary</h4>

Again, any help is appreciated.
Kathleen


--
Fabrice Lezoray
http://classes.scriptsphp.fr
-----------------------------

--- End Message ---
--- Begin Message ---
Using PHP-5.0 + OpenSSL-0.9.7c + PHP5-Openssl extension, trying to use a
specific extension section within the openssl.cnf file appears to not
work, or fail without any returned error, when specifying either/both of
"x509_extensions" and "req_extensions" in the configarg array. Only
sections defined to "x509_extensions" and "req_extensions" assigned in the
openssl.cnf file appear to be used.

--- End Message ---
--- Begin Message --- I've compiled & installed software from source before but PHP 5 is proving a challenge.

I've decompressed the tarball and cd into the directory. Run ./configure which seems to work ok but then when I do make I get the following error:

"No targets specified and no makefile found"

Sure enough there is no makefile in the directory so for some reason ./configure isn't creating one.

Can anyone offer any help?

Thanks
AW

--- End Message ---
--- Begin Message ---
Thanks!  Works like a charm!

I am the very lowest of newbies when it comes to regex
and working through your solutions has been very
educational.  I have one question about something I
couldn't figure out: 

#<h[1-9]>(.*)</h[1-9]>#Uie
`<h([1-6])>.*?</h\1)>`sie
What is the purpose of the back-ticks and the '#'? 
What are 'Uie' and  'sie'?

Thanks again!
Kathleen

-----Original Message-----
From: Fabrice Lezoray [mailto:[EMAIL PROTECTED] 
Sent: Sunday, August 01, 2004 2:52 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: regex help needed 

hi

M. Sokolewicz a écrit :
> You could try something like:
> $return = preg_replace('#<h[1-9]>(.*)</h[1-9]>#Uie',
'str_replace("<br 
> />", "", "$1")');
> 
> 
> - Tul
> 
> Kathleen Ballard wrote:
> 
>> Sorry,
>> Here is the code I am using to match the <h*> tags:
>>
>> <h([1-9]){1}>.*</h([1-9]){1}>
I think this mask is better :
`<h([1-6])>.*?</h\1)>`sie


>>
>> I have removed all the NL and CR chars from the
string
>> I am matching to make things easier.  Also, I have
run
>> tidy on the code so the tags are all uniform.
>>
>> The above string seems to match the tag well now,
but
>> I still need to remove the br tags from the tag
>> contents (.*).
To remove the <br /> tags, you need to call
preg_replace_callback() :

<?php
$str = '<h1>hi <br /> ..</h1> bla bla <h5> .... <br />
..</h5> ...<br />';
function cbk_br($match) {
        return '<h' . $match[1] . '>' . str_replace('<br />',
'', $match[2]) . 
'</h' . $match[1] . '>';
}
$return =
preg_replace_callback('`<h([1-6])>(.*?)</h\1>`si',
'cbk_br', 
$str);
echo $return;
?>

>>
>> The strings I will be matching are html formatted
>> text.  Sample <h*> tags with content are below:
>>
>> <h4>Ex-Secretary Mickey Mouse <br />Loses Mass.
>> Primary</h4>
>>
>> <h4>Ex-Secretary Mickey Mouse <br />Loses Mass.
>> Primary <br /> Wins New Jersey</h4>
>>
>> <h4>Ex-Secretary Reich Loses Mass. Primary</h4>
>>
>> Again, any help is appreciated.
>> Kathleen


-- 
Fabrice Lezoray
http://classes.scriptsphp.fr

--- End Message ---
--- Begin Message --- I've built a system which uploads a tab-delimited text file saved from Excel, then uses the text file to update a MySQL database. But when the text file contains an "é" character (confirmed by viewing in a text editor before uploading), the character is converted to some other weird character -- a capital Z with what looks like an inverted circumflex accent above it. This replacement character is stored in the database and output to HTML pages. It doesn't matter if I use htmlentites() on the data before storing in MySQL, the weird Z character is still what's written to the database. And I'm not able to do a string replacement to make it "é" again (or "&eacute;"), because when I paste the weird accented Z character into a PHP file and save, the character is converted into " }" (a space and closing bracket).

Perhaps this isn't a PHP problem, but can anyone point me towards a solution? Setup is PHP 4.3.2 on FreeBSD 4.10, Apache 1.3.27.

TIA

--
Lowell Allen

--- End Message ---
--- Begin Message ---
I'm having problems upgrading PHP from 4.2.2 to 4.3.8 on RedHat 9.  I've
tried simply making the 4.3.8 from source, but RedHat didn't use the default
PHP folder structure is seems, since there has been no change in my PHP
version.  I also tried the "./configure" string returned by 'phpinfo()'
(assuming that the correct path info was included) with no luck.  Does
anyone have any tips on an easier way to upgrade?

 

Thanks,

Will


--- End Message ---

Reply via email to