var str = 'asdfasdfsd dsafasdfav rgsrev aergzv(123) 12 12 123idfkjasefkdf'
var str2 = 'WERFREGW5EHGWRST123 12 12 123ADWEFAERGSERVFSDFVGATRHSRA4E'
var str3 = 'dsgretgrstgsrtgs123-12-12-123EQR4WEGWTRS5TGSR5FG'
function get_number(s) {
return s.match(/(\(\d{3}\)(\s\d{2}){2}\s\d{3})|(\d{3}(\s\d{2}){2}\s\d{3})|(\d{3}(-\d{2}){2}-\d{3})/)[0]
}
alert(get_number(str))
alert(get_number(str2))
alert(get_number(str3))
__________________
оляля, ололо
Последний раз редактировалось 9xakep, 19.05.2012 в 23:55.
|