Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Should match a phone number
- /^(()?d{3}())?(-|s)?d{3}(-|s)d{4}$/
- var string = "555-790-2342 is one, 555-555-2344 is another.";
- var numbers = {
- "555-790-2342" : "John Smith",
- "555-555-2344" : "Bob Smith",
- "555-324-2342" : "Dana Smith"
- };
- string.replace(/your regex here/g,function(match,sub1,sub2) {
- // for obvious reasons, use meaningful argument names!
- // now do stuff
- // optionally:
- return match;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement