Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    CBG
    CBG is offline
    New Coder
    Join Date
    Feb 2010
    Location
    UK
    Posts
    91
    Thanks
    26
    Thanked 0 Times in 0 Posts

    eregi_replace to preg_replace help

    Hi,

    Can anyone help me please, I have the below eregi_replace, but am getting an error.
    How do I change it to work with preg_replace

    Code:
    $title = eregi_replace('</?[a-z][a-z0-9]*[^<>]*>', '', $title );
    Regards,
    CBG

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Since you make no use of eregi specific patterns, this is literally as simple as using: '~</?[a-z][a-z0-9]*[^<>]*>~i' for your pattern. Simply change to preg_replace. If the pattern doesn't make use of ereg specific patterns, the only thing you need to change is adding a delimiter to the string, and if its insensitive add the i to the end.

    For this particular replace, strip_tags may be an ideal replacement though as it should operate much faster than the pattern matching (matching is a very expensive operation).
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

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