MyBB Community Forums

Full Version: Regex letters, numbers and underscores
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
Could anyone help me with mycode regex. It should only allow: letters, numbers and underscores, so:
a-z, A-Z, 0-9, _

At the moment I'm using this:
\[test\](.*?)\[/test\]
\w is the letters, numbers and underscore expression.
so that would be,
\[test\](\w+)\[/test\] 
Thanks, can you limit the number of characters as well?

@Edit:
\[test\](\w{2,20})\[/test\] 

Would that be correct?
Try this:

\[test\]([\w]{2,20})\[/test\]

The pattern you posted would match too, but I personally prefer to wrap my capture groups for readability.