diff --git a/lib/coderay/encoders/html/numbering.rb b/lib/coderay/encoders/html/numbering.rb
index 8bc6259f..e717429f 100644
--- a/lib/coderay/encoders/html/numbering.rb
+++ b/lib/coderay/encoders/html/numbering.rb
@@ -17,7 +17,7 @@ def self.number! output, mode = :table, options = {}
anchor_prefix = options[:line_number_anchors]
anchor_prefix = 'line' if anchor_prefix == true
- anchor_prefix = anchor_prefix.to_s[/\w+/] if anchor_prefix
+ anchor_prefix = anchor_prefix.to_s[/[\w-]+/] if anchor_prefix
anchoring =
if anchor_prefix
proc do |line|