![]() |
Ereg replace. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Ereg replace. (/showthread.php?tid=10607) |
Ereg replace. - El Forum - 08-06-2008 [eluser]Young Caveman[/eluser] Hi. :-) I looked for this on the web but there was not anything which I can understand ![]() I have to use ereg_replace function in my app, but ereg syntax is very hard to understand. You all can try to explain me with simple words? ![]() Ps. Just to inform you: i have to replace every string which looks like this: "-" anthing "-" to: "<div>anything</div>". Then Code: -hello- Code: <div>hello</div> I apologize but I never used this function and it's a bit complicated ![]() Thanks in advance. Don ~ Albé Ereg replace. - El Forum - 08-06-2008 [eluser]xwero[/eluser] Code: preg_replace('/-(.?)-/','<div>$1</div>',$str); Ereg replace. - El Forum - 08-06-2008 [eluser]Sam Dark[/eluser] Code: $str = preg_replace('~-([^-]+)-~', '<div>$1</div>', $str); or Code: $str = preg_replace('~-(.+?)-~', '<div>$1</div>', $str); Ereg replace. - El Forum - 08-06-2008 [eluser]Young Caveman[/eluser] Thank you. :-) |