We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
ActiveSupport::Inflector#underscore
1 parent d36fb65 commit 4c0cee8Copy full SHA for 4c0cee8
activesupport/lib/active_support/inflector/methods.rb
@@ -98,7 +98,7 @@ def underscore(camel_cased_word)
98
return camel_cased_word.to_s.dup unless /[A-Z-]|::/.match?(camel_cased_word)
99
word = camel_cased_word.to_s.gsub("::", "/")
100
word.gsub!(inflections.acronyms_underscore_regex) { "#{$1 && '_' }#{$2.downcase}" }
101
- word.gsub!(/([A-Z])(?=[A-Z][a-z])|([a-z\d])(?=[A-Z])/) { ($1 || $2) << "_" }
+ word.gsub!(/(?<=[A-Z])(?=[A-Z][a-z])|(?<=[a-z\d])(?=[A-Z])/, "_")
102
word.tr!("-", "_")
103
word.downcase!
104
word
0 commit comments