"Christophe r Brandsdal" <christopherwb@ c2i.net> wrote in message
news:u4muyvnfDH A.3700@TK2MSFTN GP11.phx.gbl...[color=blue]
> Just a little question...
>
> How do I split 12345678 into 12 34 56 78???????
>
>
> Christopher Brandsdal
>
>[/color]
Thanks!
But is there not a more easy way to do this?
:)
"Yarn" <nope@noaddress .com> skrev i melding
news:e4cUN8nfDH A.392@TK2MSFTNG P12.phx.gbl...[color=blue]
> You could try this, although it's a little funky-
>
>
> counter = 2
> myString = "12345678"
> WHILE counter <= 8
> response.write right(left("123 45678",counter) ,2)&"<br>"
> counter=counter +2
> WEND
>
>
>
> "Christophe r Brandsdal" <christopherwb@ c2i.net> wrote in message
> news:u4muyvnfDH A.3700@TK2MSFTN GP11.phx.gbl...[color=green]
> > Just a little question...
> >
> > How do I split 12345678 into 12 34 56 78???????
> >
> >
> > Christopher Brandsdal
> >
> >[/color]
>
>[/color]
First we grab the two over from the left, than two over from the right.
Than we grab the fourth over from the left, than two over from the right.
and so on..
"Christophe r Brandsdal" <christopherwb@ c2i.net> wrote in message
news:uDhrvGofDH A.3200@tk2msftn gp13.phx.gbl...[color=blue]
> Thanks!
> But is there not a more easy way to do this?
>
> :)
>
>
> "Yarn" <nope@noaddress .com> skrev i melding
> news:e4cUN8nfDH A.392@TK2MSFTNG P12.phx.gbl...[color=green]
> > You could try this, although it's a little funky-
> >
> >
> > counter = 2
> > myString = "12345678"
> > WHILE counter <= 8
> > response.write right(left("123 45678",counter) ,2)&"<br>"
> > counter=counter +2
> > WEND
> >
> >
> >
> > "Christophe r Brandsdal" <christopherwb@ c2i.net> wrote in message
> > news:u4muyvnfDH A.3700@TK2MSFTN GP11.phx.gbl...[color=darkred]
> > > Just a little question...
> > >
> > > How do I split 12345678 into 12 34 56 78???????
> > >
> > >
> > > Christopher Brandsdal
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]
Christopher Brandsdal wrote on 19 sep 2003 in[color=blue][color=green]
>> "Christophe r Brandsdal" <christopherwb@ c2i.net> wrote in message[color=darkred]
>> > How do I split 12345678 into 12 34 56 78???????
>> >[/color][/color]
> "Yarn" <nope@noaddress .com> skrev i melding[color=green]
>> You could try this, although it's a little funky-
>>
>> counter = 2
>> myString = "12345678"
>> WHILE counter <= 8
>> response.write right(left("123 45678",counter) ,2)&"<br>"
>> counter=counter +2
>> WEND[/color]
>
> But is there not a more easy way to do this?[/color]
myString="12345 678"
Dim iLoop
for iLoop = 1 to len(myString) Step 2
Response.write mid(myString,iL oop,2)
next
'Untested....bu t it should work
"Yarn" <nope@noaddress .com> wrote in message
news:e4cUN8nfDH A.392@TK2MSFTNG P12.phx.gbl...[color=blue]
> You could try this, although it's a little funky-
>
>
> counter = 2
> myString = "12345678"
> WHILE counter <= 8
> response.write right(left("123 45678",counter) ,2)&"<br>"
> counter=counter +2
> WEND
>
>
>
> "Christophe r Brandsdal" <christopherwb@ c2i.net> wrote in message
> news:u4muyvnfDH A.3700@TK2MSFTN GP11.phx.gbl...[color=green]
> > Just a little question...
> >
> > How do I split 12345678 into 12 34 56 78???????
> >
> >
> > Christopher Brandsdal
> >
> >[/color]
>
>[/color]
Try this test to make your decision on what to do.
<%
strString = "12345678"
start = Timer()
For i = 1 To 1000
RexEx(strString )
Next
response.write "RegularExpersi on = " & GetTime(start) & "<br>"
start = Timer()
For i = 1 To 1000
MidLoop(strStri ng)
Next
response.write "MidLoop = " & GetTime(start) & "<br>"
start = Timer()
For i = 1 To 1000
MidHardCode(str String)
Next
response.write "MidHardCod e = " & GetTime(start) & "<br>"
start = Timer()
For i = 1 To 1000
ArrayBreak(strS tring)
Next
response.write "ArrayBreak = " & GetTime(start) & "<br>"
Function GetTime(start)
GetTime = FormatNumber(Ti mer() - start,4)
End Function
Function MidLoop(strData )
for iLoop = 1 to len(strData) Step 2
MidLoop = mid(strData,iLo op,2) & " "
next
End Function
Function RexEx(strData)
Set regEx = New RegExp
regEx.Pattern = "(..)(?=.)"
regEx.Global = True
RexEx = regEx.Replace(s trData, "$1 ")
End Function
Function ArrayBreak(strD ata)
Dim aryData()
intLen = Len(strData)
If intLen > 0 Then
ReDim aryData((intLen \ 2) + 1)
intCount = 0
for iLoop = 1 to len(strData) Step 2
strItem = Trim(mid(strDat a,iLoop,2))
If Len(strItem) > 0 Then
aryData(intCoun t) = strItem
intCount = intCount + 1
End If
next
ArrayBreak = Trim(Join(aryDa ta," "))
End If
End Function
%>
<%
strString = "12345678"
start = Timer()
For i = 1 To 1000
RexEx(strString )
Next
response.write "RegularExpersi on = " & GetTime(start) & "<br>"
start = Timer()
For i = 1 To 1000
MidLoop(strStri ng)
Next
response.write "MidLoop = " & GetTime(start) & "<br>"
start = Timer()
For i = 1 To 1000
MidHardCode(str String)
Next
response.write "MidHardCod e = " & GetTime(start) & "<br>"
start = Timer()
For i = 1 To 1000
ArrayBreak(strS tring)
Next
response.write "ArrayBreak = " & GetTime(start) & "<br>"
Function GetTime(start)
GetTime = FormatNumber(Ti mer() - start,4)
End Function
Function MidLoop(strData )
for iLoop = 1 to len(strData) Step 2
MidLoop = mid(strData,iLo op,2) & " "
next
End Function
Function RexEx(strData)
Set regEx = New RegExp
regEx.Pattern = "(..)(?=.)"
regEx.Global = True
RexEx = regEx.Replace(s trData, "$1 ")
End Function
Function ArrayBreak(strD ata)
Dim aryData()
intLen = Len(strData)
If intLen > 0 Then
ReDim aryData((intLen \ 2) + 1)
intCount = 0
for iLoop = 1 to len(strData) Step 2
strItem = Trim(mid(strDat a,iLoop,2))
If Len(strItem) > 0 Then
aryData(intCoun t) = strItem
intCount = intCount + 1
End If
next
ArrayBreak = Trim(Join(aryDa ta," "))
End If
End Function
%>
Comment