I am working on a program that scrapes emails in Ruby, therefore simply using a regex to try to utilize .match(/some regex/) can only be part of the solution. There is no perfect regex for this problem in any language.
Either the expression accepts too many strings, resulting in false-positive matches, or valid results are excluded. I am using a regex for email "validation" (actually email "suspicion" is a more apt term) that casts a "wide net".
This strategy allows me to maximize positive results by storing the suspected addresses in an array and iterating through to deal with edge cases. This question revolves around one particular edge case.
Take for example the string:
desktop_variety_top@728x90
The logic to handle strings like this example would be to purge any string that contains no periods between the @ and then end of the string.
So we might be looking at something like:
def purge_edge_case(array)
array.reject! { |s| s.<first_condition>? && s.<second_condition>? }
end
Figuring out the two string-based conditions is where I'm currently stuck.