/ Published in: JavaScript

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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);
URL: http://oragg.com/2009/10/snipplr-for-wordpress.html
Comments
