Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Other Development Tools
 left function excluding alphabets

Author  Topic 

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-06-22 : 10:24:14
hello,
am using an XML feature to web crawl on my provider's site to get a response of an sms message sent.

Am using
[CODE]ehioze = left(sResult,3)[/CODE]

However, i only want the results of ehioze only if its numeric characters. and if there are any alphabets, it shoudl exlude it.

How woudl this be done ?

Afrika

dsdeming

479 Posts

Posted - 2005-06-22 : 10:28:03
You could use LIKE '[0-9][0-9][0-9]'

Dennis
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-06-22 : 10:29:20
Can you use isnumeric function?

Something like

If isnumeric(left(sResult,3)) then
ehioze = left(sResult,3)


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-06-22 : 10:31:24
quote:
Originally posted by dsdeming
LIKE '[0-9][0-9][0-9]'


sorry sir this is VB script. Not SQL Server

:-)
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-06-22 : 10:40:49
quote:
Can you use isnumeric function?

Something like

If isnumeric(left(sResult,3)) then
ehioze = left(sResult,3)


Madhivanan


Thanks Madhivanan,
This is good. The only thing wrong here is that i dont just want to check if the first 3 are numeric. I want to be able to read the first 3 numeric characters and exclude any alphabets. And just iterate only numeric characters.

Any advice ?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-06-22 : 10:49:18
I am not good in VBScript
Try this
Dim s,i,ehioze 
ehioze =''
for i=0 to len(sResult)-1
if isnumeric(mid(sResult,i,1)) then
ehioze =ehioze & mid(sResult,i,1)
end if
if len(ehioze)>=3 then exit for
next i



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-06-22 : 10:57:57
Did i hear you say you are not good in VB script ?

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-06-22 : 11:00:04
Well
Did that code work?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-06-22 : 11:14:37
Just a min. Its actually a long code am working with.

Would give you a feedback very soon
:-)
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-06-22 : 12:05:29
NOPE
quote:

Expected end of statement

/jim.asp, line 32

next i
-----^

Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-06-22 : 12:06:42
By the way, there were two errors you mixed up with SQL

1. The single quotation marks, which is double in ASP
2. The exit for ? does not work with ASP

Am modifying your code
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2005-06-22 : 14:11:16
... and a for loop does not require the next varable. It is:

for i = 0 to blah
..blahblah
next


Corey

Co-worker on The Wizard of Oz "...those three midgets that came out and danced, the freaked me out when I was little. But they are ok now."
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-06-22 : 14:26:41
Oh ok
thanks

sometimes, you get carried away mixing up SQL statements, .net etc
Go to Top of Page
   

- Advertisement -