I’ve got this little thing here:
def get_articles
@articles = []
Doc.column_names.each do |a|
if a.match(/^article/)
@articles << a
end
end
end
But it returns a lot of unwanted results. How would I go about discarding results it returns that end in a specific string (say, _body)?
Cheers!
How about:
Incidentally, your method can be rewritten (more compactly) as:
You can also replace the dual match with a single match containing a zero-width negative look-behind assertion, but it is less readable for the majority of people (though about 2x as fast in a quick-and-dirty test):