Welcome to HostingForumz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

ASP type question

 
Goto page 1, 2, 3
   Web Hosting Problem Solving Community! (Home) -> Webmaster RSS
Next:  Todays task.....  
Author Message
user267

External


Since: Oct 16, 2003
Posts: 71



(Msg. 1) Posted: Thu Nov 06, 2003 4:14 pm
Post subject: ASP type question
Archived from groups: alt>www>webmaster (more info?)

Say I have an alphanumeric value assigned to a variable.....say the value
was "AX128MBT"......Would it be possible to extraxt the numbers from that
variable, leaving only the letters?.....If so, how would I do it?.....

 >> Stay informed about: ASP type question 
Back to top
Login to vote
alan

External


Since: Jul 01, 2003
Posts: 56



(Msg. 2) Posted: Thu Nov 06, 2003 4:14 pm
Post subject: Re: ASP type question [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Carved in mystic runes upon the very living rock, the last words of Sam
(primetlc® webmaster) of alt.www.webmaster make plain:

 > Say I have an alphanumeric value assigned to a variable.....say the value
 > was "AX128MBT"......Would it be possible to extraxt the numbers from that
 > variable, leaving only the letters?.....If so, how would I do it?.....

You need the regular expression object:

<a style='text-decoration: underline;' href="http://msdn.microsoft.com/library/default.asp?url=/library/en-" target="_blank">http://msdn.microsoft.com/library/default.asp?url=/library/en-</a>
us/script56/html/vsobjregexp.asp

--
Alan Little
Phorm PHP Form Processor
<a style='text-decoration: underline;' href="http://www.phorm.com/" target="_blank">http://www.phorm.com/</a><!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: ASP type question 
Back to top
Login to vote
mikepage007

External


Since: Nov 06, 2003
Posts: 2



(Msg. 3) Posted: Thu Nov 06, 2003 5:14 pm
Post subject: Re: ASP type question [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

It would be easy if the numbers are always in the same position in the
variable.
You could use strNumbers=mid(strVariable, 3,3)
but if they could appear at any point you'd have to use a loop to loop
through all the characters and check if each one was numeric or not i.e.

for x=1 to len(strVariable)
strTemp=mid(strVariable, x,1)
if isnumeric(strTemp) then
strOutput=mid(strVariable,x,3) '(that's if it will always be 3 digits long
inside the string)
else
end if

next x

Mike
webmaster.RemoveThis@youclaim.co.uk
<a style='text-decoration: underline;' href="http://www.youclaim.co.uk" target="_blank">www.youclaim.co.uk</a>


"Sam (primetlc® webmaster)" <prime-tee-ell-cee.RemoveThis@tiscali.com> wrote in message
news:3faa487c_1@mk-nntp-2.news.uk.tiscali.com...
 > Say I have an alphanumeric value assigned to a variable.....say the value
 > was "AX128MBT"......Would it be possible to extraxt the numbers from that
 > variable, leaving only the letters?.....If so, how would I do it?.....
 >
 ><!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: ASP type question 
Back to top
Login to vote
spamblocked1

External


Since: Sep 19, 2003
Posts: 3499



(Msg. 4) Posted: Thu Nov 06, 2003 5:33 pm
Post subject: Re: ASP type question [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Sam (primetlc® webmaster) wrote:
 > Say I have an alphanumeric value assigned to a variable.....say the
 > value was "AX128MBT"......Would it be possible to extraxt the numbers
 > from that variable, leaving only the letters?.....If so, how would I
 > do it?.....

well I was gonna answer but before I finished I see you have two splendid
answers. IME both work ok (depending on requirements[1]), but I would
recommend the regexp version if there is a lot of data to process.

[1] Other loop structures can be employed.

--
William Tasso - <a style='text-decoration: underline;' href="http://WilliamTasso.com" target="_blank">http://WilliamTasso.com</a><!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: ASP type question 
Back to top
Login to vote
user267

External


Since: Oct 16, 2003
Posts: 71



(Msg. 5) Posted: Thu Nov 06, 2003 6:13 pm
Post subject: Re: ASP type question [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Mike Page" <mikepage007.TakeThisOut@hotmail.com> wrote in message
news:bodl0f$52f$1@titan.btinternet.com...
 > It would be easy if the numbers are always in the same position in the
 > variable.
 > You could use strNumbers=mid(strVariable, 3,3)
 > but if they could appear at any point you'd have to use a loop to loop
 > through all the characters and check if each one was numeric or not i.e.
 >
 > for x=1 to len(strVariable)
 > strTemp=mid(strVariable, x,1)
 > if isnumeric(strTemp) then
 > strOutput=mid(strVariable,x,3) '(that's if it will always be 3 digits
long
 > inside the string)
 > else
 > end if
 >
 > next x

Hmmmm....Having thought about it, all the values are 2 characters isn
size....Some have a number for the second character, and some are a two
letter combination.....But where there is a number present, it's always in
the second (last) position.....
I need to identify values that have a number in this position, and remove
the number....basically so that "AA" would remain "AA", whereas "A5" would
simply become "A"......

I'm going to have a tinker with this code you've posted Mike.....I'll let
you know how I get along......<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: ASP type question 
Back to top
Login to vote
spam3

External


Since: Jul 01, 2003
Posts: 411



(Msg. 6) Posted: Thu Nov 06, 2003 9:05 pm
Post subject: Re: ASP type question [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Sam (primetlc® webmaster) wrote:

 > Say I have an alphanumeric value assigned to a variable.....say the value
 > was "AX128MBT"......Would it be possible to extraxt the numbers from that
 > variable, leaving only the letters?.....If so, how would I do it?.....

Doesn't ASP have a regex search/replace function? For instance, in PHP,
all you need to do is:

$string=preg_replace('/[0-9]/','',$string);

Then all digits are removed. You'd think a web language would have a lot
of string manipulation functions, especially for regex.

--
Justin Koivisto - spam.RemoveThis@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: ASP type question 
Back to top
Login to vote
karim34112

External


Since: Oct 22, 2003
Posts: 353



(Msg. 7) Posted: Thu Nov 06, 2003 9:05 pm
Post subject: Re: ASP type question [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Thu, 06 Nov 2003 18:05:06 GMT, Justin Koivisto wrote:

 > Sam (primetlc® webmaster) wrote:
 >
  >> Say I have an alphanumeric value assigned to a variable.....say the value
  >> was "AX128MBT"......Would it be possible to extraxt the numbers from that
  >> variable, leaving only the letters?.....If so, how would I do it?.....
 >
 > Doesn't ASP have a regex search/replace function? For instance, in PHP,
 > all you need to do is:
 >
 > $string=preg_replace('/[0-9]/','',$string);
 >
 > Then all digits are removed. You'd think a web language would have a lot
 > of string manipulation functions, especially for regex.

It does:
<a style='text-decoration: underline;' href="http://msdn.microsoft.com/library/en-us/script56/html/vsproPattern.asp?fra" target="_blank">http://msdn.microsoft.com/library/en-us/script56/html/vsproPattern.asp?fra</a>
me=true

Karim<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: ASP type question 
Back to top
Login to vote
user104

External


Since: Jun 28, 2003
Posts: 1662



(Msg. 8) Posted: Thu Nov 06, 2003 10:15 pm
Post subject: Re: ASP type question [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Justin Koivisto" <spam DeleteThis @koivi.com> wrote in message
news:m3wqb.692$Uz.17572@news7.onvoy.net...

 > Doesn't ASP have a regex search/replace function? For instance, in PHP,
 > all you need to do is:

He he! I *knew* someone was going to show how to do it with PHP!
--
Charles Sweeney
<a style='text-decoration: underline;' href="http://www.CharlesSweeney.com" target="_blank">www.CharlesSweeney.com</a><!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: ASP type question 
Back to top
Login to vote
spam3

External


Since: Jul 01, 2003
Posts: 411



(Msg. 9) Posted: Thu Nov 06, 2003 10:25 pm
Post subject: Re: ASP type question [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Charles Sweeney wrote:

 > "Justin Koivisto" <spam DeleteThis @koivi.com> wrote in message
 > news:m3wqb.692$Uz.17572@news7.onvoy.net...
 >
  >>Doesn't ASP have a regex search/replace function? For instance, in PHP,
  >>all you need to do is:
 >
 > He he! I *knew* someone was going to show how to do it with PHP!

Fault me. I don't know ASP, but I saw the looping solutions posted, and
couldn't see why. I figured there was a way to do it with a single
function call (which it seems I was dead wrong).

Besides, that Karim jerk always likes to say how ASP is so superior...
*ducks*

--
Justin Koivisto - spam DeleteThis @koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: ASP type question 
Back to top
Login to vote
spamblocked1

External


Since: Sep 19, 2003
Posts: 3499



(Msg. 10) Posted: Thu Nov 06, 2003 10:34 pm
Post subject: Re: ASP type question [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Justin Koivisto wrote:
 > Charles Sweeney wrote:
 >
  >> "Justin Koivisto" <spam.DeleteThis@koivi.com> wrote in message
  >> news:m3wqb.692$Uz.17572@news7.onvoy.net...
  >>
   >>> Doesn't ASP have a regex search/replace function? For instance, in
   >>> PHP, all you need to do is:
  >>
  >> He he! I *knew* someone was going to show how to do it with PHP!

I was holding my breath

 > Fault me. I don't know ASP, but I saw the looping solutions posted,
 > and couldn't see why. I figured there was a way to do it with a single
 > function call (which it seems I was dead wrong).

ASP - The Regular Expression (Regexp) Object provides simple regular
expression support.

Guess you must've missed those posts ;o)

--
William Tasso - <a style='text-decoration: underline;' href="http://WilliamTasso.com" target="_blank">http://WilliamTasso.com</a><!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: ASP type question 
Back to top
Login to vote
spam3

External


Since: Jul 01, 2003
Posts: 411



(Msg. 11) Posted: Thu Nov 06, 2003 10:49 pm
Post subject: Re: ASP type question [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

William Tasso wrote:

 > Justin Koivisto wrote:
 >
  >>Charles Sweeney wrote:
  >>
  >>
   >>>"Justin Koivisto" <spam RemoveThis @koivi.com> wrote in message
   >>>news:m3wqb.692$Uz.17572@news7.onvoy.net...
   >>>
   >>>
   >>>>Doesn't ASP have a regex search/replace function? For instance, in
   >>>>PHP, all you need to do is:
   >>>
   >>>He he! I *knew* someone was going to show how to do it with PHP!
 >
 >
 > I was holding my breath
 >
 >
  >>Fault me. I don't know ASP, but I saw the looping solutions posted,
  >>and couldn't see why. I figured there was a way to do it with a single
  >>function call (which it seems I was dead wrong).
 >
 > ASP - The Regular Expression (Regexp) Object provides simple regular
 > expression support.

No, I saw them, but in order to do what I had suggested, it looks like
you need to create the function (at least from the posts I saw) like so:

Function regex_replace(patternStr, replacementStr, subjectStr)
Dim regEx, str1
Set regEx = New RegExp
regEx.Pattern = patternStr
regex_replace = regEx.Replace(subjectStr, replacementStr)
End Function

(Assuming that is valid ASP syntax of course...)

So then, what the OP wanted would be similar to (again, I don't know ASP
syntax):

alphanumeric_value = regex_replace("[0-9]", "", alphanumeric_value);

Am I correct, or am I just not understanding ASP at all (or missing an
existing function that does this)?

--
Justin Koivisto - spam RemoveThis @koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: ASP type question 
Back to top
Login to vote
user104

External


Since: Jun 28, 2003
Posts: 1662



(Msg. 12) Posted: Thu Nov 06, 2003 10:53 pm
Post subject: Re: ASP type question [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Justin Koivisto" <spam RemoveThis @koivi.com> wrote in message
news:jexqb.700$Uz.17805@news7.onvoy.net...
 > Charles Sweeney wrote:
 >
  > > "Justin Koivisto" <spam RemoveThis @koivi.com> wrote in message
  > > news:m3wqb.692$Uz.17572@news7.onvoy.net...
  > >
   > >>Doesn't ASP have a regex search/replace function? For instance, in PHP,
   > >>all you need to do is:
  > >
  > > He he! I *knew* someone was going to show how to do it with PHP!
 >
 > Fault me. I don't know ASP, but I saw the looping solutions posted, and
 > couldn't see why. I figured there was a way to do it with a single
 > function call (which it seems I was dead wrong).
 >
 > Besides, that Karim jerk always likes to say how ASP is so superior...
 > *ducks*

Just having fun Justin! I don't know ASP either. I think someone mentioned
using a Regular Expression with ASP.

I see our *friend* responded predictably!
--
Charles Sweeney
<a style='text-decoration: underline;' href="http://www.CharlesSweeney.com" target="_blank">www.CharlesSweeney.com</a><!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: ASP type question 
Back to top
Login to vote
spam3

External


Since: Jul 01, 2003
Posts: 411



(Msg. 13) Posted: Thu Nov 06, 2003 10:58 pm
Post subject: Re: ASP type question [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Charles Sweeney wrote:
 > Just having fun Justin! I don't know ASP either. I think someone mentioned
 > using a Regular Expression with ASP.

I know you are, and so am I. However, I do have a slight interest in the
topic...

 > I see our *friend* responded predictably!

He did? where? ...oh yeah, I'll have to un-plonk him for this thread. LOL!

--
Justin Koivisto - spam DeleteThis @koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: ASP type question 
Back to top
Login to vote
spamblocked1

External


Since: Sep 19, 2003
Posts: 3499



(Msg. 14) Posted: Thu Nov 06, 2003 11:35 pm
Post subject: Re: ASP type question [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Justin Koivisto wrote:
 > William Tasso wrote:
 >
  >> Justin Koivisto wrote:
  >>
   >>> Charles Sweeney wrote:
   >>>
   >>>
   >>>> "Justin Koivisto" <spam DeleteThis @koivi.com> wrote in message
   >>>> news:m3wqb.692$Uz.17572@news7.onvoy.net...
   >>>>
   >>>>
   >>>>> Doesn't ASP have a regex search/replace function? For instance, in
   >>>>> PHP, all you need to do is:
   >>>>
   >>>> He he! I *knew* someone was going to show how to do it with PHP!
  >>
  >>
  >> I was holding my breath
  >>
  >>
   >>> Fault me. I don't know ASP, but I saw the looping solutions posted,
   >>> and couldn't see why. I figured there was a way to do it with a
   >>> single function call (which it seems I was dead wrong).
  >>
  >> ASP - The Regular Expression (Regexp) Object provides simple regular
  >> expression support.
 >
 > No, I saw them, but in order to do what I had suggested, it looks like
 > you need to create the function ...
 >
 > Am I correct, or am I just not understanding ASP at all (or missing an
 > existing function that does this)?

yep - I'd say you were right. AFAIK there is no constant or inbuilt function
that defines alpha characters in vbScript, but hey, let's not get into a bum
sniffing, hand-bag waving frenzy over this. I'm sure there's better ways to
idle our time.

Each environment has its own intrinsic advantages as well as rather odd
characteristics and foibles.

What I will add is this: I recently did some troubleshooting on an
application that used both ASP/vbScript and PHP. Constantly switching
between the two (three if you include the nightmare of client-side
Javascript - of course there was HTML as well - makes 4) was a real PITA.

--
William Tasso - <a style='text-decoration: underline;' href="http://WilliamTasso.com" target="_blank">http://WilliamTasso.com</a><!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: ASP type question 
Back to top
Login to vote
sherry_anne

External


Since: Jul 10, 2003
Posts: 22



(Msg. 15) Posted: Fri Nov 07, 2003 3:12 am
Post subject: Re: ASP type question [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Came forth ->>Sam (primetlc® webmaster) <<- saying:

 >Hmmmm....Having thought about it, all the values are 2 characters isn
 >size....Some have a number for the second character, and some are a two
 >letter combination.....But where there is a number present, it's always in
 >the second (last) position.....
 >I need to identify values that have a number in this position, and remove
 >the number....basically so that "AA" would remain "AA", whereas "A5" would
 >simply become "A"......
 >
 >I'm going to have a tinker with this code you've posted Mike.....I'll let
 >you know how I get along......
 >

if it's ALWAYS 2 chars long then here's a function for you.

Function SwitcharooBuckaroo(str)
Dim i
i = Asc(Right(str, 1))
If i > 47 And i < 58 Then
SwitcharooBuckaroo = Left(str, 1)
Else
SwitcharooBuckaroo = str
End If
End Function


Also, if you don't want to run every value through the function then
just pull it out of the function, and just do the check w/out doing
the modifying --unless necessary.

/tired.

I mean:
10 aRec=rs.GetRows()
20 cnt=UBound(aRec,2)
30 for i = 0 to cnt
40 z = Asc(Right(aRec(0,i), 1)) //test that element
50 if (z>47 and z<5Cool { //only change if qualifies
60 aRec(0,i)=left(aRec(0,i),1)
70 end if
80 next
90 //at this point your array will be filled with values you like


But I suggest the function unless you're doing hundreds of thousands
of records and stack space is a problem.


.......

and onto off topic news Razz

if anyone missed me here's what I've been up to:
<a style='text-decoration: underline;' href="http://www.cactusblossom.org/photos.asp" target="_blank">http://www.cactusblossom.org/photos.asp</a>

And i'm pretty burned out on stuff in general so, that's why i've not
been participatory, sorry :/


hth, Sam
btw, are you Fatwa?

Sherry
--
ck out: <a style='text-decoration: underline;' href="http://allmyfaqs.com/faq.pl?How_to_post" target="_blank">http://allmyfaqs.com/faq.pl?How_to_post</a>
In da works again: <a style='text-decoration: underline;' href="http://www.CactusBlossom.org" target="_blank">www.CactusBlossom.org</a><!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: ASP type question 
Back to top
Login to vote
Display posts from previous:   
   Web Hosting Problem Solving Community! (Home) -> Webmaster All times are: Pacific Time (US & Canada) (change)
Goto page 1, 2, 3
Page 1 of 3

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]