Global replace?

Results 1 to 2 of 2

Thread: Global replace?

  1. #1
    Join Date
    Dec 1969

    Default Global replace?

    Hi, I&#039;ve been reading the FAQs on the replace function and it seems to be used to replace particular words within known strings (e.g changing all occurences of "Gruvn is a genius" to "Bill is a genius").<BR><BR>This is not quite what I want to do. I have a table full of a huge amount of numbers (from and access db), and I want to replace particular values with different values (Eg find all occurrences of "4.999999" and replace it with "&#062;5", and several similar variations). This seems like it should be simple, but none of my "replaceables" are strings nor do they lie within strings - they are good, old fashioned numbers.. Is it as simple as I&#039;m hoping?<BR><BR>Mike

  2. #2
    Join Date
    Dec 1969

    Default Nope.

    You could certainly ROUND all the numbers (could even do that in the SQL query). But there&#039;s no replace on numbers.<BR><BR>Hmmm...well, maybe I&#039;m speaking too soon...<BR><BR>You *COULD* create a function, maybe?<BR><BR>&#060;%<BR>Function NumReplace( num )<BR> If num &#062; 4.9999 AND num &#060;= 5 Then num = 5<BR> ElseIf num &#060;= 95 AND num &#060;= 105 Then num = 100<BR> ElseIf ...<BR> ...<BR> End If<BR> NumReplace = num<BR>End Function<BR>%&#062;<BR><BR>And then every place you used one of these maybe-to-be converted numbers in your code, invoke the function:<BR><BR>&#060;%<BR>Response.Write "Your normalized score is " & NumReplace( RS("Score") )<BR>%&#062;<BR><BR>But that sure seems yucky.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts