Re: How to do this ?
- From: "Leslie Milburn" <CDB4W@xxxxxxxxxxxxxxxxxx>
- Date: Fri, 24 Feb 2006 00:19:25 +1000
Thanks Jan.
"janM" <bion@xxxxxxxxx> wrote in message
news:43fd7dc7$1@xxxxxxxxxxxxxxxxxxxxxxxxxxx
Hey Leslie,
Here is a way to do it:
;-----------------
method cmReplaceStringContent(strToCorrectString string,
strToReplace string,
strReplaceWith string) string
var
strBGN, strEND string
endvar
try
if strToCorrectString.advMatch("^(..)" + strToReplace +
"(..)$",
strBGN,
strEND) then
return cmReplaceStringContent(strBGN,
strToReplace,
strReplaceWith) +
strReplaceWith +
cmReplaceStringContent(strEND,
strToReplace,
strReplaceWith)
else
return strToCorrectString
endif
onfail
errorclear()
return strToCorrectString
endtry
endMethod
;------------------------
;Example:
method pushButton(var eventInfo Event)
var
arToStrip Array[] string
strInput string
strResult string
liLoop longint
endvar
try
;TESTING INPUT STRING:
strInput = "L !@es `l*(i ~9{8%5_&e M<>?,2)8./-i l$b|=[]u = 3^r 5+}\\8#n"
;characters to strip"~`!@#$%^&*()_+-=[]{}\\|;:'\",./<>? "
;initialize
strResult = ""
;optional
arToStrip.empty()
;fill the array with characters to strip
;arToStrip.addLast("~") ; this character first stripped before "for" loop
;special opal characters preceed with "\\"
arToStrip.addLast("`")
arToStrip.addLast("!")
arToStrip.addLast("\\@")
arToStrip.addLast("#")
arToStrip.addLast("\\$")
arToStrip.addLast("%")
arToStrip.addLast("\\^")
arToStrip.addLast("&")
arToStrip.addLast("\\*")
arToStrip.addLast("\\(")
arToStrip.addLast("\\)")
arToStrip.addLast("_")
arToStrip.addLast("\\+")
arToStrip.addLast("-")
arToStrip.addLast("=")
arToStrip.addLast("\\[")
arToStrip.addLast("\\]")
arToStrip.addLast("{")
arToStrip.addLast("}")
arToStrip.addLast("\\\\")
arToStrip.addLast("\\|")
arToStrip.addLast(";")
arToStrip.addLast(":")
arToStrip.addLast("'")
arToStrip.addLast(chr(34)) ;"\\"" or chr(34)
arToStrip.addLast(",")
arToStrip.addLast(".")
arToStrip.addLast("/")
arToStrip.addLast("<")
arToStrip.addLast(">")
arToStrip.addLast("\\?")
arToStrip.addLast(chr(32)) ;space
;first input the strInput
strResult = cmReplaceStringContent(strInput, chr(126), "") ;~
;loop through the rest of the string to strip further with characters from
the array
for liLoop from 1 to arToStrip.size()
strResult = cmReplaceStringContent(strResult, arToStrip[liLoop], "")
endfor
strResult.view() ;result = Lesli985eM28ilbu3r58n
onfail
errorclear()
endtry
endMethod
;--------------
Jan
.
- References:
- How to do this ?
- From: Leslie Milburn
- Re: How to do this ?
- From: janM
- How to do this ?
- Prev by Date: Re: How to do this ?
- Next by Date: Re: How to do this ?
- Previous by thread: Re: How to do this ?
- Index(es):