我了解捕获组开头的问号 (?:pattern) 表示此模式不应创建反向引用,但在以下示例中,问号位于捕获组末尾之后是什么意思通配符?
self =~ /(.*?)_(\d+)$/
代码
class String
# used to instantiate a model based on a dom_id style
# identifier like "person_10"
def to_model
self =~ /(.*?)_(\d+)$/
class_name, id = $1, $2
class_name.classify.constantize.find(id)
end
end