The js implementation extracts Numbers from strings


< ! PUBLIC DOCTYPE HTML ”- / / / / W3C DTD XHTML 1.0 Transitional / / EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd” > < HTML XMLNS = “http://www.w3.org/1999/xhtml” > < Head> < Meta HTTP - equiv = “content-type” Content = “text/HTML. Charset = gb2312 ”/ > < Title> Js implementation extracts Numbers from strings < / title> < Script language = “javascript” type = “text/javascript” > The function getNum (text) { Var value = text. Replace (/ [^ 0-9] / ig, ""); Alert (value); } < / script> < / head>

< Body> < Input type = “text” id = “btn_getNum” / > < Input type=“button” value=” get the number “onclick=“getNum(btn_getnum.value);” / > < / body> < / html>