Adam Posted December 26, 2008 Share Posted December 26, 2008 Got a probs common problem with a greedy dot! I'm trying to get around it by supplying characters it can't be. Here's an example: [tag]SELECT THIS![/tag] and [tag]SELECT THIS SEPERATELY![/tag] The problem I'm getting is that it's returning the whole string, it's finding the first occurence of [tag] and the very last occurence of [/tag]. My regular expression looks like this at the minute: \[tag\].+\[\/tag\] I've tried many variations like: \[tag\][^\[\/tag\]]+\[\/tag\] But they are treated as individual characters instead of as a whole word. Anybody know a solution?? Cheers! A Quote Link to comment Share on other sites More sharing options...
DarkWater Posted December 26, 2008 Share Posted December 26, 2008 http://www.phpfreaks.com/tutorial/regular-expressions-part1---basic-syntax/page5 Add a ? after the + next to the dot. .+? Quote Link to comment Share on other sites More sharing options...
Adam Posted December 26, 2008 Author Share Posted December 26, 2008 Perfect cheers! A 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.