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. 5 15683 vu******@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/d...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.
On May 14, 12:06 pm, "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom>
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/d...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
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')
%>
<script language='javascript' runat='server'>
function insertFifth(s,inser){
return s.replace(/(.{5})/g,"$1"+inser);
};
</script>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Evertjan. wrote:
>There may be a regular expression solution for this
"may", "simplicity"?
<%
reponse.write insertFifth('12345678901234567890123','x')
%>
<script language='javascript' runat='server'>
function insertFifth(s,inser){
return s.replace(/(.{5})/g,"$1"+inser);
};
</script>
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.
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') %>
<script language='javascript' runat='server'> function insertFifth(s,inser){ return s.replace(/(.{5})/g,"$1"+inser); }; </script>
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) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: sathia |
last post by:
Hi, I have this table:
CREATE TABLE `osservatorio` (
`id` int(10) unsigned NOT NULL auto_increment,
`testo` varchar(255) NOT NULL default '',
`parent` int(11) default NULL,...
|
by: Ralph Guzman |
last post by:
TASK:
I have to generate a report with all categories, subcategories and
products in database.
PROBLEM:
I want to write one query that will return:
1. category
2. subcategory: determined by...
|
by: Rich Wallace |
last post by:
All,
I receive an xml doc with an element which contains a & in the data. I
am attempting to insert the data into a SQL Server database and I want to
convert the & to a "&" character before I...
|
by: how can i insert a image to SQLServer? |
last post by:
I want to insert some strings and images which from
richTextBox into SQLServer.
I could insert it into SQLServer,such as follows:
FileStream s=new FileStream...
|
by: Rich |
last post by:
Hello,
I have to create a table in an Access mdb (remotely) on
the fly.
Create Table tbl1(fld1 Integer, fld2 varchar(10), fld3...)
Then I have to insert data:
Insert Into tbl1 Values(" &...
|
by: AMP |
last post by:
I have a string:(actually its a line turned into a string)
"30 40 04 40 FF 3F 31 40 00 39 B0 12 4E 40 B0 12'
in c strlen() gives me 49
but c# :
LinetoString = infile.ReadLine();
linelen=...
|
by: John Nagle |
last post by:
I have XML replies in a DOM which contain entity escapes,
like "&". What's the proper way to replace them with
the ordinary characters? Preferably something that will work in
most browsers?
I...
|
by: jonathan184 |
last post by:
The code seems to be working fine for some records but I am thinking it is finding some other records with special characters and so on. I am looking for a way to insert the xml string with escaping...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |