Ruby has a built-in File class for similar cases.
fname = File.basename(str, '.*') # "U6342_Account_20150112"
fname.split('_') # ["U6342", "Account", "20150112"]
Or, in short:
File.basename(str, '.*').split('_')
Edit: the second parameter in basename tells the function what suffix the file has. It supports the * wildcard to match any suffix, and then removes it from the result. Examples:
File.basename(str, '.*') # "U6342_Account_20150112"
File.basename(str, '.txt') # "U6342_Account_20150112"
File.basename(str, '.jpg') # "U6342_Account_20150112.txt" => suffix not removed
Read more here http://ruby-doc.org/core-2.2.0/File.html#method-c-basename