This is a discussion on preg_replace driving me nuts! within the alt.comp.lang.php forums, part of the PHP Programming Forums category; I've got code to blindly remove '<.*?>' from email messages. It works if I dump the message to ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I've got code to blindly remove '<.*?>' from email messages. It works if I
dump the message to a file and then read it in. If I just work on the block of text directly it doesn't work. Anyone experienced this before? It's nerve wracking! Greg B. |
|
|||
|
On 2004-01-28, Greg Brondo <greg@brondo.com> wrote:
> I've got code to blindly remove '<.*?>' from email messages. It works if I > dump the message to a file and then read it in. If I just work on the block > of text directly it doesn't work. Anyone experienced this before? It's > nerve wracking! Provide us with the lines in your code where you have the pattern matching, so we can have a look at it. -- http://home.mysth.be/~timvw |
|
|||
|
On 2004-01-28, Greg Brondo <greg@brondo.com> wrote:
> I've got code to blindly remove '<.*?>' from email messages. It works if I > dump the message to a file and then read it in. If I just work on the block > of text directly it doesn't work. Anyone experienced this before? It's > nerve wracking! If you use output buffering, you could run tidy on the contents of the page, and then output the lot. -- http://home.mysth.be/~timvw |
|
|||
|
function get_stripped_block () {
return preg_replace ("/<.*?>/", '', $this->get_block()); } function get_block () { $block = $this->from . "\n" . $this->subject . "\n" . $this->body; return $block; } That's the two functions. What happens is it completey removes a block of the text instead of replacing '<.*?>' with "". If I write the test to a file and then read it back in and run the function above, it works correctly. Could it be a end-of-line conversion that is triggering it? Also, the functions work with other blocks of text and fails on others.... It's very odd. Thanks! Greg B. "Tim Van Wassenhove" <euki@pi.be> wrote in message news:bv9na1$pntv1$2@ID-188825.news.uni-berlin.de... > On 2004-01-28, Greg Brondo <greg@brondo.com> wrote: > > I've got code to blindly remove '<.*?>' from email messages. It works if I > > dump the message to a file and then read it in. If I just work on the block > > of text directly it doesn't work. Anyone experienced this before? It's > > nerve wracking! > > Provide us with the lines in your code where you have the pattern > matching, so we can have a look at it. > > -- > http://home.mysth.be/~timvw |
|
|||
|
Greg Brondo wrote:
> I've got code to blindly remove '<.*?>' from email messages. It works if I > dump the message to a file and then read it in. If I just work on the block > of text directly it doesn't work. Anyone experienced this before? It's > nerve wracking! > > Greg B. > > try changing your preg_replace pattern to /<.*?>/s I was having troubles with pregs, in my case the other way around, from a file untill I added the s pattern modifier, not sure if this will solve your problem, it's just a guess as I was having a very simaler one. ~Cameron |
|
|||
|
Argh!!! I cannot believe I missed that! Thanks much!
Greg B. "Cameron" <foo@bar.invalid> wrote in message news:bve0eq$jdl$1@newsg3.svr.pol.co.uk... > Greg Brondo wrote: > > I've got code to blindly remove '<.*?>' from email messages. It works if I > > dump the message to a file and then read it in. If I just work on the block > > of text directly it doesn't work. Anyone experienced this before? It's > > nerve wracking! > > > > Greg B. > > > > > > try changing your preg_replace pattern to > > /<.*?>/s > > I was having troubles with pregs, in my case the other way around, from > a file untill I added the s pattern modifier, not sure if this will > solve your problem, it's just a guess as I was having a very simaler one. > > ~Cameron |
|
|||
|
Greg Brondo wrote:
> Argh!!! I cannot believe I missed that! Thanks much! > > Greg B. > > > "Cameron" <foo@bar.invalid> wrote in message > news:bve0eq$jdl$1@newsg3.svr.pol.co.uk... > >>Greg Brondo wrote: >> >>>I've got code to blindly remove '<.*?>' from email messages. It works > > if I > >>>dump the message to a file and then read it in. If I just work on the > > block > >>>of text directly it doesn't work. Anyone experienced this before? It's >>>nerve wracking! >>> >>>Greg B. >>> >>> >> >>try changing your preg_replace pattern to >> >>/<.*?>/s >> >>I was having troubles with pregs, in my case the other way around, from >>a file untill I added the s pattern modifier, not sure if this will >>solve your problem, it's just a guess as I was having a very simaler one. >> >>~Cameron > > > *Grins* no problem, I know how regex's can be a PITA, oh and just a little nit pick now I have been nice, if you could bottom post we would appriciate it ;) ~Cameron |