johnnyk Posted June 14, 2006 Share Posted June 14, 2006 Why doesn't/<OL><LI>.[^<\/LI>]*<\/LI>/smatch<OL><LI><OL TYPE="a"><LI TYPE="a">text.</LI>Wouldn't . include <OL TYPE="a"><LI TYPE="a">Also, if I wanted to make it single line and case insensitive, what would I do? Would it just be /regex/si? Quote Link to comment https://forums.phpfreaks.com/topic/11936-regex/ Share on other sites More sharing options...
poirot Posted June 14, 2006 Share Posted June 14, 2006 It won't match that because of the negated characters. Something like this:[code]/<OL><LI>(.*?)<\/LI>/s[/code]Would make more sense. For case insensitive matching, use the PCRE_CASELESS modifier (i). For single line only, remove the PCRE_DOTALL modifier (s). [code]/<OL><LI>(.*?)<\/LI>/i[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11936-regex/#findComment-45300 Share on other sites More sharing options...
johnnyk Posted June 14, 2006 Author Share Posted June 14, 2006 So what exactly was wrong with my regex. I thought it said "match any characters (except for a bullet end), until you find a bullet end."And what if I wanted it to not stop at \n (/regex/s) AND be case insensitive (/regex/i)? How would I combine them? Quote Link to comment https://forums.phpfreaks.com/topic/11936-regex/#findComment-45308 Share on other sites More sharing options...
poirot Posted June 14, 2006 Share Posted June 14, 2006 It says "match any characters except <, /, L, I and >". As it is in a character class, each character is considered independent.Simply use /pattern/siIt doesn't matter the order (so it could be /pattern/is); everything outside the delimiter is considered a pattern modifier. Quote Link to comment https://forums.phpfreaks.com/topic/11936-regex/#findComment-45312 Share on other sites More sharing options...
johnnyk Posted June 15, 2006 Author Share Posted June 15, 2006 More regex - why isn't/<DL><DD>(.*?)<\/DD>/simatching<I>text.</I> [b]<DL><DD>text.</DD>[/b]</DL><HR ALIGN="LEFT" ..... Quote Link to comment https://forums.phpfreaks.com/topic/11936-regex/#findComment-46015 Share on other sites More sharing options...
effigy Posted June 15, 2006 Share Posted June 15, 2006 It does.[code]<?php $string = '<I>text.</I> <DL><DD>text.</DD></DL><HR ALIGN="LEFT"'; if (preg_match('/<DL><DD>(.*?)<\/DD>/si', $string)) { print 'matched'; }?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11936-regex/#findComment-46038 Share on other sites More sharing options...
johnnyk Posted June 15, 2006 Author Share Posted June 15, 2006 Oh man my fault. I just realized I used strip_tags() to strip everything but <ol> and <li>. Thanks alot. Quote Link to comment https://forums.phpfreaks.com/topic/11936-regex/#findComment-46041 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.