---
title: "ASP 只截取字符串的数字"
author: "haimav"
date: "2009-09-28T14:15:46Z"
tags: ["ASP"]
slug: "asp"
draft: false
lastmod: "2009-09-28T14:15:46Z"
id: 479444
url: "https://haimav.iteye.com/blog/479444"
---

&lt;%  
function RegExpTestsp(str,pat)  
     Dim r, Match, Matches  
     Set r = New RegExp  
     r.Pattern = pat  
     r.IgnoreCase = false  
     r.Global = True  
     Set Matches = r.Execute(str)  
     For Each Match in Matches  
     RetStr = RetStr & Match.Value  
     Next  
     RegExpTestsp = RetStr  
End function  
Html2="4044.667767,108589.827011 鍖呭ご甯?姘戞棌瑗胯矾瑗垮崡80绫?鍥㈢粨鍔犳补绔欒タ鍖?0绫? "  
pat="\[\\d]+"  
Response.Write RegExpTestsp(Html2,pat)

%&gt;

 

这是一个方法

&lt;%

Html2="3088.266079,12440.195633 鏉 窞甯?鍑よ捣涓滆矾;鏉 窞甯備釜浣撳姵鍔ㄨ 呭崗浼氳タ鍖?0绫? "

Response.write mid(html2,1,instr(Html2," "))  
Response.end  
    
For N = 0 To Len(Html2)  
    Na = N+1  
    st=mid(Html2,Na,1)  
    
    if st="." or st="," then  
     st1=st1+st    
       elseif IsNumeric(st) then  
    st1=st1+st    
     end if  
Next

Response.write st1

%&gt;