Professional Web Applications Themes

preg_replace driving me nuts! - PHP Development

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

  1. #1

    Default preg_replace driving me nuts!

    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.


    Greg Brondo Guest

  2. #2

    Default Re: preg_replace driving me nuts!

    On 2004-01-28, Greg Brondo <gregbrondo.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.

    --
    [url]http://home.mysth.be/~timvw[/url]
    Tim Van Wassenhove Guest

  3. #3

    Default Re: preg_replace driving me nuts!

    On 2004-01-28, Greg Brondo <gregbrondo.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.

    --
    [url]http://home.mysth.be/~timvw[/url]
    Tim Van Wassenhove Guest

  4. #4

    Default Re: preg_replace driving me nuts!

    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" <eukipi.be> wrote in message
    news:bv9na1$pntv1$2ID-188825.news.uni-berlin.de...
    > On 2004-01-28, Greg Brondo <gregbrondo.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.
    >
    > --
    > [url]http://home.mysth.be/~timvw[/url]

    Greg Brondo Guest

  5. #5

    Default Re: preg_replace driving me nuts!

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

  6. #6

    Default Re: preg_replace driving me nuts!

    Argh!!! I cannot believe I missed that! Thanks much!

    Greg B.


    "Cameron" <foobar.invalid> wrote in message
    news:bve0eq$jdl$1newsg3.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 Guest

  7. #7

    Default Re: preg_replace driving me nuts!

    Greg Brondo wrote:
    > Argh!!! I cannot believe I missed that! Thanks much!
    >
    > Greg B.
    >
    >
    > "Cameron" <foobar.invalid> wrote in message
    > news:bve0eq$jdl$1newsg3.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
    Cameron Guest

Similar Threads

  1. Please help - this has been driving me nuts!
    By I R Godzilla webforumsuser@macromedia.com in forum Macromedia Director Basics
    Replies: 2
    Last Post: February 3rd, 11:27 PM
  2. DateTime driving me nuts
    By Simple Simon in forum ASP.NET General
    Replies: 1
    Last Post: July 28th, 11:35 PM
  3. Driving me nuts
    By Joshua Ghiloni in forum PHP Development
    Replies: 1
    Last Post: July 24th, 10:38 AM
  4. format driving me nuts
    By bob in forum ASP.NET General
    Replies: 0
    Last Post: July 15th, 01:41 AM
  5. error code driving me nuts
    By tommytomato webforumsuser@macromedia.com in forum Macromedia Dynamic HTML
    Replies: 0
    Last Post: July 8th, 03:37 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139