Contd VBScript |
||
![]() ![]() Delta Cpt dopel Dim str, iName, oName, inFile, outFile, fsObj, thisLine
Set fsObj = CreateObject("Scripting.FileSystemObject")
iName = "C:\in.txt"
oName = "C:\out.txt"
Set inFile = fsObj.OpenTextFile(iName, 1)
Set outFile = fsObj.CreateTextFile(oName,1)
While Not inFile.AtEndOfStream
thisLine = inFile.Readline
If LCase(strip(thisLine)) = LCase(strip(reverseWord(thisLine))) Then
outFile.WriteLine(thisLine)
End If
Wend
inFile.Close()
outFile.Close()
Public Function strip(ByVal str)
Dim oRegEx, str
Set oRegEx = New RegExp
oRegEx.Pattern = "[^a-z0-9]"
oRegEx.IgnoreCase = True
oRegEx.Global = True
str = oRegEx.Replace(str, "")
strip = str
End Function
Public Function reverseWord(ByVal str)
Dim i, head, tail, md, ptr
md = ""
ptr = 1
ub = Len(str)
lb = Round((Len(str)/2)+.001)
If ub = 1 Then
reverseWord = str
Exit Function
End If
For i = ub To lb+1 Step -1
head = head & Mid(str, i, 1)
tail = Mid(str, ptr, 1) & tail
If (ptr >= i) Then
Exit For
End If
ptr = ptr + 1
Next
If (Len(str) Mod 2) <> 0 Then
md = Mid(str, lb, 1)
End If
reverseWord = head & md & tail
End Function
Replies:
|
||
| CyberArmy::Forum v0.6 Generated In 0.00785 seconds |