Jump to content
xisto Community
Sign in to follow this  
galexcd

Help With Preg_replace

Recommended Posts

I must be a total noob, or just really tired...............-.- either way, I cannot understand what exactly those funky strings preg_replace wants for the pattern.Could sombody explain to me exactly what the pattern string and the replace string in preg replace does?I get str_replace... that's quite basic.I considered myself a pro at php until tonight........haha shows how much i know. I bet tomorow, if i look it up I'll get it....Anyway.. any help? Thanks..... :lol:

Share this post


Link to post
Share on other sites

It needs a regular expression as a pattern.If you dont know that what are regular expressions it is quite simple to leasrn it. Just google it out OR go visit the php.net site where they have explained the whole function in details and read the comments below.That help alot and have links to some great PHP related regular expressions.But if you are using preg_replace to takecare of HTML tags or BBCODE it is useless.Hope that helps

Share this post


Link to post
Share on other sites

Great help.. Thanks,

but why is it useless for bb code? because that's the reason I wanted to know.. Right now my message boards sorta suck because I'm using str_replace fore the bbcode, It's sorta annoying how you have to put url name every time, instead of also allowing http://www.mydomain.com/.

I've also got a flash chat, and stupid flash's html has to be perfect, so <b><i>text</b></i> would leave the bold modifyer on. I was hoping for a way to use preg_replace to disable bbcode within bbcode for the chat.

Share this post


Link to post
Share on other sites

Well if you are using it for URL it is fine but make sure to make it ungreedy so that it matches not the whole thing but first start and first end.Let me see if i have that for the URL stuff.

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  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.