473,386 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

trouble with LEFT function

My results after doing some stuff are going to have names separated by
commas. Example:

James & Beth Williams John & Mary Smith Ross & Rachel Gellar Willy & Wanda
Wonka
But the number of names is variable, so I put in commas between each one.
Then I end up with:

, James & Beth Williams, John & Mary Smith, Ross & Rachel Gellar, Willy &
Wanda Wonka

This is almost what I need, except that first comma. To get rid of it, I
tried doing a replace of the first character on the left, like this:

strFullName = Replace(strFullName,Left(strFullName,1),"")

However, this is yielding weird results.

What am I doing wrong in my replace function?
Jan 4 '08 #1
5 2295
you could use the mid function

Mid(string, start[, length])

strFullName = Mid( strFullName , 2 )
Jan 4 '08 #2
I am not familiar with Mid.

At any rate, I got this error when I tried it:

Microsoft VBScript compilation (0x800A03EE)
Expected ')'
/dev/groupevents.asp, line 59, column 17
Mid(string, start[, length])
Jan 4 '08 #3
"Middletree" <mi********@hottttttttmail.comwrote in message
news:OP**************@TK2MSFTNGP04.phx.gbl...
I am not familiar with Mid.

At any rate, I got this error when I tried it:

Microsoft VBScript compilation (0x800A03EE)
Expected ')'
/dev/groupevents.asp, line 59, column 17
Mid(string, start[, length])
Consider reading the manual:-

http://msdn2.microsoft.com/en-us/lib...7y(VS.85).aspx

Mid(string, start[, length])

--
Anthony Jones - MVP ASP/ASP.NET
Jan 4 '08 #4
Middletree wrote on 04 jan 2008 in
microsoft.public.inetserver.asp.general:
My results after doing some stuff are going to have names separated by
commas. Example:

James & Beth Williams John & Mary Smith Ross & Rachel Gellar Willy &
Wanda Wonka
But the number of names is variable, so I put in commas between each
one. Then I end up with:

, James & Beth Williams, John & Mary Smith, Ross & Rachel Gellar,
Willy & Wanda Wonka

This is almost what I need, except that first comma. To get rid of it,
I tried doing a replace of the first character on the left, like this:

strFullName = Replace(strFullName,Left(strFullName,1),"")

However, this is yielding weird results.

What am I doing wrong in my replace function?
I suppose you assume VBscript, which is not the only ASP language.

Try:

Dim t
t = ", James & Beth Williams, John & Mary Smith, Ross & Rachel Gellar"
t = Replace(t,", ","",1,1)

Explanation:
replacing the comma+space: ", "
with an empty string: ""
starting at the first letter: 1
and only once: 1

===============

Or using mid():

Dim t
t = ", James & Beth Williams, John & Mary Smith, Ross & Rachel Gellar"
t = mid(t,3)

Explanation:
new string t starts at the 3rd letter of the old one

===============

using ASP-j[ava]script is also a good option
making one line regex possible:

var t;
t = ', James & Beth Williams, John & Mary Smith, Ross & Rachel Gellar';
t = t.replace(/^, /,'');

Explanation:
replace
from the start: ^
the comma+space: ", "
non global: so only once
with an empty string ''

===============

I would urge you to read the specs on functions you use and not assume
them.

Download script56.chm:
<http://www.microsoft.com/downloads/>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 4 '08 #5
Dim t
t = ", James & Beth Williams, John & Mary Smith, Ross & Rachel Gellar"
t = Replace(t,", ","",1,1)
This did the trick. I had no idea Replace function allowed a starting ans
stopping point. Thanks very much.
Jan 4 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Steven Spear | last post by:
Hi. I am trying to perform backtracking with this search function. Something is going wrong when I enter 2 at the command line. Entering 1 at the command line seems to work fine. I notice that...
4
by: Kurt | last post by:
I'm using the fConcatChild function posted at http://www.mvps.org/access/modules/mdl0004.htm to return a field from the Many table of a 1:M relationship into a concatenated string. The function...
3
by: Morten Snedker | last post by:
If I have a number of random applications open, move the mouse cursor to a given position and do a click, the application gets the focus. That is what this simple code should illustrate: Dim...
1
TMS
by: TMS | last post by:
I'm trying to write an address book that is based on a binary tree. I'm devloping in Visual C++ (I blew up my Ubuntu with the new dist, so no EMACS), starting with the basics: #ifndef...
5
by: Amoril | last post by:
I've read quite a few different message on various boards and for some reason I'm still having trouble wrapping my head around this viewstate maintenance and trying to get these dynamically created...
2
by: execworks | last post by:
I would appreciate help with the following Function. The SQL statement below returns a Recordcount = 0, yet, when it runs in the query designer it returns the correct count of 40 Private...
17
Ganon11
by: Ganon11 | last post by:
Hey guys, OK, taking care of this beforehand; I AM a student in a university. This IS part of my homework, and (as a moderator), I'm doing my best to follow the posting guidelines I work so hard...
3
by: Michellevt | last post by:
Hi I am working on a project (for college) and wondered if anyone can help me with my problem. In the project we are not allowed to make use of any "style" attributes but "class" attributes...
1
by: ced69 | last post by:
having trouble getting marquee to work get object required errors tring t <title>This Month at the Chamberlain Civic Center</title> <link href="styles.css" rel="stylesheet"...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.