Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: FW:Correction Re: Obtaining a value from text


Message #1 by "Larry Woods" <larry@l...> on Tue, 2 Jul 2002 10:38:11 -0700
Correction:

To be "100%", change the occurrences of "match(0)" to
"match.item(0)" .  Also note that the IsNumeric test will
validate scientific notation; e.g., 10+ or 10- will return "true"
from IsNumeric---in case that might be a problem.

Larry Woods


-----Original Message-----
From: Larry Woods [mailto:larry@l...]
Sent: Tuesday, July 02, 2002 9:13 AM
To: ASP Web HowTo
Subject: [asp_web_howto] Re: Obtaining a value from text


Here you go, Craig.

Just copy the following as some xxx.asp file and execute.  This
not only shows you how to do it, but the document will allow you
to test various combinations of characters to see if they contain
a number.  The algorithm only tests for numbers at the BEGINNING
of the string. characters allowed are 0-9, + and -.

Hope this helps....

Larry Woods



<html>
<head/>
<body>
<form name="frm" action="TestRegExp.asp" method="POST">

<%
if len(request("Input"))<>0 then
	Dim oRegExp
	set oRegExp=CreateObject("VBScript.RegExp")
	oRegExp.Global=False
	oRegExp.Pattern="[0-9,\.,\+,-]*"
	Dim match
	set match=oRegExp.Execute(request("Input"))
	if match.count<>0 then
		if isnumeric(match(0)) then
			response.write match(0) & " is a number"
		else
			response.write "No number detected in " & request("Input")
		end if
	end if
end if
%>
<p>Enter a string: <input type=text name=Input /></p>
<input type=submit name=submit value="Send Value"/>
</form>
<body>
</html>





  Return to Index