Hi, Bram
How about something like this:
<CODE>
'Program to demonstrate the removal of all characters in a string
' not in the range A-Z, a-z, 0-9, and not _.
Option Explicit
Dim iaryTranslate(256) 'Global Keep-Character Table
Call InitializeTranslationTable 'Initialize only once
MsgBox KeepSomeChars("N'o]w+_")
MsgBox KeepSomeChars("Now is the time ';;/?.>," & _
"for all good men to come to the aid of their country." & _
Chr(0) & Chr(255) & "and then some!")
wscript.quit
Function KeepSomeChars(strInput)
Dim i, straryTemp()
reDim straryTemp(len(strInput))
For i = 1 to len(strInput)
straryTemp(i) = iaryTranslate(Asc(Mid(strInput,i,1)))
next
KeepSomeChars = join(straryTemp, "")
End Function
Sub InitializeTranslationTable
'Translates the 'keeper' characters to themselves.
'Translates all others to empty strings.
Dim i 'Loop index
For i = 0 to 255
iaryTranslate(i) = ""
Next
For i = Asc("A") to ASC("Z")
iaryTranslate(i) = Chr(i)
Next
For i = Asc("a") to ASC("z")
iaryTranslate(i) = Chr(i)
Next
For i = Asc("0") to ASC("9")
iaryTranslate(i) = Chr(i)
Next
iaryTranslate(Asc("_")) = "_"
End Sub
</CODE>
-Paul Randall
Quote:
> hello,
> I want to replace all characters in a string from my
> database that are not numbers or lettters or _
> I want to get rid of all that other characters so that
> only numbers, letters and _ remain, even spaces need
> to be cleared !
> Problem is that i cannot use regular expressions on
> my server => unix server with third party asp software.
> How can i manage this ? (without reg exp ! )
> tnx a lot guys !