ngreenwood6 Posted August 6, 2010 Share Posted August 6, 2010 I came up with this solution all on my own knowing no regex at all '/(\[)(adapter)(=\")(.*)(\"\])/i' All I wanted this to do was match this: [adapter=test] or this:[adapter=""]. I was just wondering if there is a better way to do this and to match it on this as well [adapter] because currently it wont match that. Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted August 6, 2010 Share Posted August 6, 2010 Something like: '/\[adapter[="]*(.*?)["]?\]/i' Should match: [adapter=test] [adapter=""] [adapter] [adapter=test] Quote Link to comment Share on other sites More sharing options...
Adam Posted August 6, 2010 Share Posted August 6, 2010 Try: '/\[adapter(?:=")?(.*?)"?\]/i' Edit Or if you want to enable single or double quotes, but make sure they match: preg_match('/\[adapter(?:=(["\']))?(.*?)\\1\]/i', $str, $matches, PREG_OFFSET_CAPTURE) 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.