Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. // Should match a phone number
  2. /^(()?d{3}())?(-|s)?d{3}(-|s)d{4}$/
  3.  
  4. var string = "555-790-2342 is one, 555-555-2344 is another.";
  5.  
  6. var numbers = {
  7. "555-790-2342" : "John Smith",
  8. "555-555-2344" : "Bob Smith",
  9. "555-324-2342" : "Dana Smith"
  10. };
  11.  
  12. string.replace(/your regex here/g,function(match,sub1,sub2) {
  13. // for obvious reasons, use meaningful argument names!
  14. // now do stuff
  15. // optionally:
  16. return match;
  17. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement