Square brackets don't mean what you think they mean. Use (?:...) to group things without capturing, and use the ? suffix to make something optional.
/^(\w+)(?:_(\w+))?$/
In reply to Re: simple regexp problem
by ikegami
in thread simple regexp problem
by jeanluca
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |