Yes, no problem! Glad it worked out. you may wish to actually study the
perlre man page on perl.com. This goes into the most details and talks about
how PERL actually EXTENDS shell regular expressions significantly and
excellent resource that I have used many many times.

I figure since PHP regexps are perl compatible, might as well go to the
source, no?

My other suggestion is that if you are taking this HTML and putting into a
database, especially MySQL you should scrub for pipes, nulls and slashes,
hackers can exploit user input to open a tty or shell or even access user
files like /etc/passwd and mess wid ya.... here are a few regexps that do
that

For pipes:
preg_replace('/\|/g','',$html_string);
 For nulls:
Preg_replace('/\0/g','',$html_string);
For slashes
preg_replace('/\//g','',$html_string);  # to be clearer, you can use s!\/!
g; just so you can see where the regexp begins and ends.


Some other useful ones for data like the stuff you're doing:
Spaces at the beginning:
/^\s/
spaces at the end:
/\s$/
<br> tags into \n
preg_replace('!\<br\>!', "\n", $string);

regular expressions are key.. if you have an editor like bbedit on the mac
or UltraEdit on the PC it will make your life SO much easier. Especially if
you are a database massager, oh man the hours I have saved!

C.




-----Original Message-----
From: Noah [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 29, 2003 12:34 PM
To: Carl Furst
Subject: Re: [PHP] strip_tags() Quandry....

Hey Carl.

Sorry for the late reply -- got totally wrapped up in utilizing that highly
useful bit of reg exp code.

Thanks for the heads up; it certainly solved the problem.

Unfortunately, or fortunately, new problems have arisen -- time to dive into
learning some reg exp syntax........

Thanks again,

--Noah


----- Original Message -----
From: "Carl Furst" <[EMAIL PROTECTED]>
To: "CF High" <[EMAIL PROTECTED]>
Sent: Tuesday, May 27, 2003 8:49 PM
Subject: RE: [PHP] strip_tags() Quandry....


use regular expressions:

preg_replace("/\s+/"," ",$html_string);

-----Original Message-----
From: CF High [mailto:[EMAIL PROTECTED]
Sent: Tuesday, May 27, 2003 11:57 PM
To: [EMAIL PROTECTED]
Subject: [PHP] strip_tags() Quandry....


Hey all.

I've got a chunk of HTML text I'd like to format for insertion into our
mySql db.

Let's say $html_string equals the following:

<tr>
    <td>1</td>
    <td>Bardo, Jesse</td>
    <td>S</td>
    <td>A</td>
    <td>Andover, MA</td>
</tr>

To setup this chunk of text for insertion I first use
strip_tags($html_string); that results in:

1
Bardo, Jesse
S
A
Andover, MA

I then use str_replace(",","",$html_string) to create a space delimited
string.

Here's where I believe the problem occurs.  There are apparently numerous
blank spaces within the string.  I've tried replacing the blank spaces, or
whatever is separating the data to no avail.

I've tried a number of aimless efforts to get the string properly formatted,
but no luck -- any suggestions?

Thanks for helping me over this hurdle.......

--Noah



--
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

Reply via email to