/ Published in: JavaScript
URL: http://oragg.com/2009/10/snipplr-for-wordpress.html
Expand |
Embed | Plain Text
function pick(str, re) { var result = str.match(re); return (result && result.length === 2) ? result[1] : result; } var str = "tel: 13512345678"; var tel_a = pick(str, /tel:\s?(\d+)/); var tel_b = pick(str, /tel:(\d+)/); // return 13512345678 alert(tel_a); // return null alert(tel_b);
You need to login to post a comment.
