Cut String & Insert in String

Cut String & Insert in String

am 14.05.2007 17:32:23 von vunet.us

Hello,
In ASP, VBScript:
How can I display the first 20 characters of a long string?
How can I insert some character inside of the string on every 5th
character?
Thank you for help.

Re: Cut String & Insert in String

am 14.05.2007 18:06:42 von reb01501

vunet.us@gmail.com wrote:
> Hello,
> In ASP, VBScript:
> How can I display the first 20 characters of a long string?

first20 = left(longstring,20)

> How can I insert some character inside of the string on every 5th
> character?

There may be a regular expression solution for this, but for
simplicity's sake:

dim i, oldstring,newstring, stringseg,subst_char
for i = 1 to len(oldstring) step 5
stringseg=mid(oldstring,i,5)
if len(newstring) > 0 then
newstring = newstring & subst_char & stringseg
else
newstring=stringseg
end if
next

> Thank you for help.

The vbscript documentation can be downloaded from:
http://www.microsoft.com/downloads/details.aspx?FamilyID=015 92c48-207d-4be1-8a76-1c4099d7bbb9&DisplayLang=en

or it can be read online at
http://msdn2.microsoft.com/en-us/library/t0aew7h6.aspx

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Re: Cut String & Insert in String

am 14.05.2007 18:54:06 von vunet.us

On May 14, 12:06 pm, "Bob Barrows [MVP]"
wrote:
> vunet...@gmail.com wrote:
> > Hello,
> > In ASP, VBScript:
> > How can I display the first 20 characters of a long string?
>
> first20 = left(longstring,20)
>
> > How can I insert some character inside of the string on every 5th
> > character?
>
> There may be a regular expression solution for this, but for
> simplicity's sake:
>
> dim i, oldstring,newstring, stringseg,subst_char
> for i = 1 to len(oldstring) step 5
> stringseg=mid(oldstring,i,5)
> if len(newstring) > 0 then
> newstring = newstring & subst_char & stringseg
> else
> newstring=stringseg
> end if
> next
>
> > Thank you for help.
>
> The vbscript documentation can be downloaded from:http://www.microsoft.com/downloads/details.aspx?FamilyI D=01592c48-207...
>
> or it can be read online athttp://msdn2.microsoft.com/en-us/library/t0aew7h6.aspx
>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.

thank you veeeery much

Re: Cut String & Insert in String

am 14.05.2007 21:29:36 von exjxw.hannivoort

Bob Barrows [MVP] wrote on 14 mei 2007 in
microsoft.public.inetserver.asp.general:

>> How can I insert some character inside of the string on every 5th
>> character?
>
> There may be a regular expression solution for this, but for
> simplicity's sake:
>
> dim i, oldstring,newstring, stringseg,subst_char
> for i = 1 to len(oldstring) step 5
> stringseg=mid(oldstring,i,5)
> if len(newstring) > 0 then
> newstring = newstring & subst_char & stringseg
> else
> newstring=stringseg
> end if
> next
>

> There may be a regular expression solution for this

"may", "simplicity"?

<%
reponse.write insertFifth('12345678901234567890123','x')
%>



--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Re: Cut String & Insert in String

am 14.05.2007 21:48:34 von reb01501

Evertjan. wrote:

>> There may be a regular expression solution for this
>
> "may", "simplicity"?
>
> <%
> reponse.write insertFifth('12345678901234567890123','x')
> %>
>
>

Yes! Simplicity!
Go ahead. Tell the user how to interpret that regexp, as well as how to
create it, the next time he needs something like this.

Simplicity isn't always about the number of lines of code involved.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Re: Cut String & Insert in String

am 14.05.2007 22:20:11 von exjxw.hannivoort

Bob Barrows [MVP] wrote on 14 mei 2007 in
microsoft.public.inetserver.asp.general:

> Evertjan. wrote:
>
>>> There may be a regular expression solution for this
>>
>> "may", "simplicity"?
>>
>> <%
>> reponse.write insertFifth('12345678901234567890123','x')
>> %>
>>
>>
>
> Yes! Simplicity!
> Go ahead. Tell the user how to interpret that regexp, as well as how to
> create it, the next time he needs something like this.

Sorry Bob, I fail to see that.
The earlier vbscirpt example was not explained.

Usenet is an interactive medium, so anyone is free to ask.

> Simplicity isn't always about the number of lines of code involved.

Simplicity is in the hands of the beholder.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)