Guest User

Untitled

a guest
Sep 20th, 2013
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.43 KB | None | 0 0
  1. require 'pp'
  2. def extract_emails_to_array(txt)
  3.     reg = /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/i
  4.     txt.scan(reg).uniq
  5. end
  6. def extract_numbers_to_array(txt)
  7.     reg = /(?:\+?|\b)[0-9]{10}\b/i
  8.     txt.scan(reg).uniq
  9. end
  10.  
  11. string = '<div class="footer_area"><center>Contact Us- +91665865753  Mobile - +91 324 878 994  Email - [email protected] or [email protected]</br>';
  12.  
  13. pp extract_emails_to_array(string)
  14. pp extract_numbers_to_array(string)
Advertisement
Add Comment
Please, Sign In to add comment