I hate Regex - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: I hate Regex (/showthread.php?tid=14604) Pages:
1
2
|
I hate Regex - El Forum - 01-08-2009 [eluser]Iverson[/eluser] Crazy question... I'm addicted to the substr function, but there doesn't seem to be a way to do this using a regex. I know about preg match and preg replace, bla bla bla, but this doesn't serve my purpose. I need to extract a string when I don't know what the actual string will be. I only know what the surrounding text will be. I hate Regex - El Forum - 01-08-2009 [eluser]Eric Cope[/eluser] Would an XML parser do the trick? I hate Regex - El Forum - 01-08-2009 [eluser]TheFuzzy0ne[/eluser] preg_match() does exactly this. http://uk.php.net/manual/en/function.preg-match.php There are other functions that server a similar function, such as eregi(), and ereg(). Use brackets to capture the text you want. If you're serious about learning Regular Expressions, you can check out the great tutorials [url="http://www.regular-expressions.info/"]here[/url]. Just bear in mind that there are different types of Regular Expressions that use different syntaxes, for example, preg_match() uses Perl regular Expressions. Code: <?php I hate Regex - El Forum - 01-08-2009 [eluser]Iverson[/eluser] [quote author="Eric Cope" date="1231469450"]Would an XML parser do the trick?[/quote] I like the way you think! I just finished putting it in somewhat of an XML format: Code: <title>Column Title</title> Too bad CI doesn't have a neat XML parser. I'll look into using SimpleXML. |