richard@bouncingfox.co.uk Posted January 4, 2008 Share Posted January 4, 2008 Hi, For a very simple forum i have made my own little bit of code for entering URL's etc similar to the ones used by most main forum systems but the regex bit doesn't work properly. Here is the little preg_match code: $num_url = preg_match_all("#\[url=.{3,}\].{1,}\[/url\]#",$value,$results); echo "num url:" . $num_url; $value contains the origin string. In theory what i was aiming for was any string with [url=(then min of 3 characters, for now)](min 1 character link)[/url] I thought it was working fine up until today and its not liking this input: Welcome to the Escape Network, We now have a proper site address [url=http://www.escape-network.co.uk]www.escape-network.co.uk[/url] and a mailing list [url=http://escape-network.co.uk/mailman/listinfo]HERE[/url], once you are signed up and confirmed anyone can send a message to all the members. You will need to sign up, after you have confirmed your email then i can set your access level to network member (if you are one!). Refer to the [url=forums.php?page=viewthread&id=1]Welcome Thread[/url] for info on stuff that is still being made. Feel free to sign up browse and break it, if anything does break let me know (email link in bottom left). By signing up you will have access to more options pictures and be able to contribute. [b]If people are having problems with the pop-up windows let me know[/b] It returns the number of url's to be 2 not 3 and even if i add another url link it only recognises the first 2 Can anyone see what silly mistake i have made??! Thanks in advance Rich Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted January 4, 2008 Share Posted January 4, 2008 thats because there is a newline the the third url Quote Link to comment Share on other sites More sharing options...
richard@bouncingfox.co.uk Posted January 4, 2008 Author Share Posted January 4, 2008 Thanks for the reply, Where i am testing this there is no newline and its still not working this is the output after running the script: Welcome to the Escape Network, We now have a proper site address www.escape-network.co.uk and a mailing list HERE, once you are signed up and confirmed anyone can send a message to all the members. You will need to sign up, after you have confirmed your email then i can set your access level to network member (if you are one!). Refer to the [url=forums.php?page=viewthread&id=1]Welcome Thread[/url] for info on stuff that is still being made. Feel free to sign up browse and break it, if anything does break let me know (email link in bottom left). By signing up you will have access to more options pictures and be able to contribute. If people are having problems with the pop-up windows let me know Even removing the space between the Welcome Thread bit makes no difference. Quote Link to comment Share on other sites More sharing options...
richard@bouncingfox.co.uk Posted January 4, 2008 Author Share Posted January 4, 2008 I've half solved the problem by using $num_url = preg_match_all("#\[url=(.*?)\](.*?)\[/url\]#",$value,$results); but this means no characters can be entered and it still works. I tried lots of other combinations but this seems to be the only one that works on all 3 links in the message at the same time. Quote Link to comment Share on other sites More sharing options...
effigy Posted January 4, 2008 Share Posted January 4, 2008 #\]{3,})\](.+?)\[/URL\]#s Quote Link to comment Share on other sites More sharing options...
richard@bouncingfox.co.uk Posted January 4, 2008 Author Share Posted January 4, 2008 Many thanks all sorted now. Learning more about these as i go. what does the 's' on the end do i have seen it somewhere else but never any description of it? Thanks for your help Quote Link to comment Share on other sites More sharing options...
effigy Posted January 4, 2008 Share Posted January 4, 2008 It's a pattern modifier. Quote Link to comment 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.