jeff205 Posted July 31, 2009 Share Posted July 31, 2009 I have this regex: /(\[code\])(.*)(\[b\])(.+)(\[\/b\])(.*)(\[\/code\])/Usi I need it to check if the open and close ]code[ tags are not there, instead of how it is now where it checks if they are there. Is there a way of doing this with regex? Quote Link to comment https://forums.phpfreaks.com/topic/168228-regex-check-if-string-does-not-exist/ Share on other sites More sharing options...
.josh Posted July 31, 2009 Share Posted July 31, 2009 kwds: negative lookaround or you could just like, do if(!preg_match(....)) { ... } Quote Link to comment https://forums.phpfreaks.com/topic/168228-regex-check-if-string-does-not-exist/#findComment-887350 Share on other sites More sharing options...
sarathi Posted July 31, 2009 Share Posted July 31, 2009 I found that a negative look behind is ?<! and a negative look ahead is ?!, but I can't find the right way to implement them into my code. /(?<!\[(code|html|css|javascript|php|gml)\])(.*)(\[b\])(.+)(\[\/b\])(.*)(?!\[\/\\2\])/Usi I've tried this, and few other ways, but I none of them have works, does anyone know how I could correctly implement them to check if there is not a code tag before, and there is not a /code tag after? Quote Link to comment https://forums.phpfreaks.com/topic/168228-regex-check-if-string-does-not-exist/#findComment-887352 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.