3raser Posted June 3, 2012 Share Posted June 3, 2012 I've decided that knowing a good portion of Regex is a necessity. Sadly, starting out always seems to be the hardest. In the following expression, I attempt to match anything that starts with . Like so: /\[quote=[a-zA-Z0-9]\]/g So for instance, I'd like for it to match something like this: [quote=bob] Any reasons why it doesn't seem to work? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/263566-my-start-to-regex/ Share on other sites More sharing options...
Pikachu2000 Posted June 3, 2012 Share Posted June 3, 2012 Tags were all hosed. Fixed that for ya. Quote Link to comment https://forums.phpfreaks.com/topic/263566-my-start-to-regex/#findComment-1350730 Share on other sites More sharing options...
3raser Posted June 3, 2012 Author Share Posted June 3, 2012 Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/263566-my-start-to-regex/#findComment-1350732 Share on other sites More sharing options...
requinix Posted June 3, 2012 Share Posted June 3, 2012 [a-zA-Z0-9] By itself that means only one. It would work with quote=b. Add a "quantifier" to it - which one depends on what you want to allow. Quote Link to comment https://forums.phpfreaks.com/topic/263566-my-start-to-regex/#findComment-1350742 Share on other sites More sharing options...
3raser Posted June 3, 2012 Author Share Posted June 3, 2012 [a-zA-Z0-9] By itself that means only one. It would work with quote=b. Add a "quantifier" to it - which one depends on what you want to allow. I'm not looking for just quote=b. :/ I'm looking for [tt] [tt] Quote Link to comment https://forums.phpfreaks.com/topic/263566-my-start-to-regex/#findComment-1350746 Share on other sites More sharing options...
requinix Posted June 3, 2012 Share Posted June 3, 2012 [a-zA-Z0-9] By itself that means only one. It would work with quote=b. Add a "quantifier" to it - which one depends on what you want to allow. I'm not looking for just quote=b. :/ I'm looking for [tt] [tt] Right. Which is why you should add a quantifier. Quote Link to comment https://forums.phpfreaks.com/topic/263566-my-start-to-regex/#findComment-1350749 Share on other sites More sharing options...
3raser Posted June 3, 2012 Author Share Posted June 3, 2012 Ah hah, I got it working. \[quote=[a-zA-Z0-9]+\] Quote Link to comment https://forums.phpfreaks.com/topic/263566-my-start-to-regex/#findComment-1350756 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.