• Sign in to Neowin Faster!

    Create an account on Neowin to contribute and support the site.

  • 0
Sign in to follow this  

ereg_replace

Question

Endoscient    0

so i have this

$input = ereg_replace('\[font="([[:graph:]]+)"\]([[:graph:]]+)\[/font\]', '<font class="\\1">\\2</font>', $input);

which works fine except when there is a lind break after the . please help....

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0
sinatosk    0
so i have this

$input = ereg_replace('\[font="([[:graph:]]+)"\]([[:graph:]]+)\[/font\]', '<font class="\\1">\\2</font>', $input);

which works fine except when there is a lind break after the . please help....

try this

$input = preg_replace('#\[font="([[:graph:]]+)"\]([[:graph:]]+)\[/font\]#s', '<font class="\\1">\\2</font>', $input);

use preg_xxx functions instead of ereg_xxx functions because preg_xxx are faster

am not fully sure what "[:graph:]" is but I never seen it in preg_xxx before

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.