fixes #2685 incorrect and inefficient regexp checking madium name format

It takes eternity to compute something like this:

"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa  b" =~ /\A(\S+\s?)+\Z

Also "this is wrong " was not matched