Jump to content

My start to Regex


3raser

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/263566-my-start-to-regex/
Share on other sites

[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.

Link to comment
https://forums.phpfreaks.com/topic/263566-my-start-to-regex/#findComment-1350749
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.