/^([a-zA-Z0-9+])(?:_(\w+))?$/ [download]
or
/^((?:(?!_)\w)+)(?:_(\w+))?$/ [download]
In reply to Re^2: simple regexp problem by ikegami in thread simple regexp problem by jeanluca