[Resolved] preg_replace certain html entities
Results 1 to 3 of 3

Thread: [Resolved] preg_replace certain html entities

  1. #1
    Member
    Join Date
    Oct 2002
    Posts
    75

    preg_replace certain html entities

    due to xhtml restrictions, i have to remove all html entities that are not & > < ",etc.. decimal entities ({ etc) are not the problem, btw.

    tried this code

    PHP Code:
    preg_replace('/&((?!amp)|(?!gt)|(?!lt)|(?!quot));/i','',$i); 
    but it fails..

    also tried preg_replace_callback but it fails since the function that replaces the text is a class method.

    and last of all, no luck with the /e flag to execute mulitple lines of php code..

    please help..
    Last edited by buraks78; 01-06-2005 at 05:38 PM.

  2. #2
    Senior Member xblue's Avatar
    Join Date
    Dec 2002
    Location
    Europe
    Posts
    1,100
    I think you are on the right track with lookaheads (though 1 lookahead should be enough), but as far as I can see your pattern is requiring the semicolon to directly follow the ampersand, which doesn't seem to be what you want. try

    Code:
    /&(?!(amp|gt|lt|quot))[a-z]+;/i'
    No keyboard found. Press F1 to continue...

  3. #3
    Member
    Join Date
    Oct 2002
    Posts
    75
    yep... that worked perfectly.. thank you very much.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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