I am having trouble translating this into Ruby.
Here is a piece of JavaScript that does exactly what I want to do:
function get_code(str){
return str.replace(/^(Z_.*): .*/,"$1");
}
I have tried gsub, sub, and replace but none seem to do what I am expecting.
Here are examples of things I have tried:
"Z_sdsd: sdsd".gsub(/^(Z_.*): .*/) { |capture| capture }
"Z_sdsd: sdsd".gsub(/^(Z_.*): .*/, "$1")
"Z_sdsd: sdsd".gsub(/^(Z_.*): .*/, "#{$1}")
"Z_sdsd: sdsd".gsub(/^(Z_.*): .*/, "\1")
"Z_sdsd: sdsd".gsub(/(.).*/) { |capture| capture }