diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb
index <HASH>..<HASH> 100644
--- a/activerecord/lib/active_record/relation/calculations.rb
+++ b/activerecord/lib/active_record/relation/calculations.rb
@@ -333,7 +333,7 @@ module ActiveRecord
     def select_for_count
       if @select_values.present?
         select = @select_values.join(", ")
-        select if select !~ /(,|\*)/
+        select if select !~ /[,*]/
       end
     end
 
diff --git a/railties/lib/rails/generators/generated_attribute.rb b/railties/lib/rails/generators/generated_attribute.rb
index <HASH>..<HASH> 100644
--- a/railties/lib/rails/generators/generated_attribute.rb
+++ b/railties/lib/rails/generators/generated_attribute.rb
@@ -32,7 +32,7 @@ module Rails
           case type
           when /(string|text|binary|integer)\{(\d+)\}/
             return $1, :limit => $2.to_i
-          when /decimal\{(\d+)(,|\.|\-)(\d+)\}/
+          when /decimal\{(\d+)[,.-](\d+)\}/
             return :decimal, :precision => $1.to_i, :scale => $3.to_i
           else
             return type, {}
rewrites a couple of alternations in regexps as character classes

Character classes are the specific regexp construct
to express alternation of individual characters.