Hi,
Can someone please tell me how to capitalise all words in a string
that are seperated by spaces. The string is variable and not the same
every time hence I cant use the Ucase function as I wont know the
exact position of the start of each word.
Cheers....John 7 6811
John Aspinall wrote: Hi,
Can someone please tell me how to capitalise all words in a string that are seperated by spaces. The string is variable and not the same every time hence I cant use the Ucase function as I wont know the exact position of the start of each word.
Cheers....John
? Why won't UCase work? Please provide an example string, and SHOW the
result you wish to obtain. Do you wish to do proper casing (capitalize only
the first letter of each word)?
Bob Barrows
--
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]" <re******@NOyah oo.SPAMcom> wrote: John Aspinall wrote: Hi,
Can someone please tell me how to capitalise all words in a string that are seperated by spaces. The string is variable and not the same every time hence I cant use the Ucase function as I wont know the exact position of the start of each word.
Cheers....John
? Why won't UCase work?
Because OP wants the first letter of each word uppercase, the rest
lowercase. Something like this might do it in VBScript (this is not
tested!!):
's1 is a string containing blank-separated words.
'The first letter of each word is to be capitalized
set re = new RegExp
re.pattern = " [a-z]"
re.global = "true"
re.replace(s1, ucase($1))
--
Tim Slattery
MS MVP(DTS) Sl********@bls. gov http://www.aspfaq.com/2299
-- http://www.aspfaq.com/
(Reverse address to reply.)
"John Aspinall" <jo***********@ yahoo.co.uk> wrote in message
news:24******** *************** ***@posting.goo gle.com... Hi,
Can someone please tell me how to capitalise all words in a string that are seperated by spaces. The string is variable and not the same every time hence I cant use the Ucase function as I wont know the exact position of the start of each word.
Cheers....John
Tim Slattery wrote: "Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote:
John Aspinall wrote: Hi,
Can someone please tell me how to capitalise all words in a string that are seperated by spaces. The string is variable and not the same every time hence I cant use the Ucase function as I wont know the exact position of the start of each word.
Cheers....John
? Why won't UCase work?
Because OP wants the first letter of each word uppercase, the rest lowercase.
Where do you see that in his post? Why do you leap from "capitalise all
words " to "first letter of each word uppercase"? He could just as easily
have wanted something like this:
abcd efg hijkl mn op
to become this:
abcd EFG hijkl MN op
Or something equally bizarre.
I congratulate you for going to the trouble of writing that code based on a
guess about what the OP wanted. I hope your guess was correct so your time
was not wasted
--
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.
> I hope your guess was correct so your time was not wasted
Exactly why I post links to existing code instead of writing it over and
over again. :-)
After all, if it's not what they wanted (and even sometimes when it is),
I'll hear about it... :-)
Sorry, I explained this poorly. Yes I did want just the first letter of
each word capitalised and Im using VBScript.
Thanks.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote in message
news:OZ******** ******@TK2MSFTN GP10.phx.gbl... Tim Slattery wrote: "Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote:
John Aspinall wrote: Hi,
Can someone please tell me how to capitalise all words in a string that are seperated by spaces. The string is variable and not the same every time hence I cant use the Ucase function as I wont know the exact position of the start of each word.
Cheers....John
? Why won't UCase work?
Because OP wants the first letter of each word uppercase, the rest lowercase.
Where do you see that in his post? Why do you leap from "capitalise all words " to "first letter of each word uppercase"? He could just as easily have wanted something like <snip>
It is an easy and fair deduction to make from the OP: "I can't use the
Ucase function as I wont know the exact position of the start of each word"
can only mean that he wants to capitalize the start of each word. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Nige |
last post by:
Repost - as some readers took got sidetracked.
To save me re-inventing the wheel, does anyone have a function to
capitalise each word in form data? I was thinking along the lines of
capitalise the first letter of the string, then any other letter after a
space or hyphen.
So many users seem to think that just because they are online they can
use addresses like "8 brown road, chatham, kent" and so I have to
manually change them.
|
by: Rick |
last post by:
I have a program that reads from a file. In the file are a series of
words. I read in all the words into a string array, find the average
length, count the number of words, display the longest word and how long
it is, and display the smallest word and how long it is. All that is
working fine, but what I need to do it format certain words that contain
a period at the end of them (ex: a word at the end of a sentence), words
with quotes...
|
by: derrick |
last post by:
I used to program text RPG's in C back in high school, but I was very crude
at it and only learned what I needed to get the job done. I am now about to
graduate college with a degree in English and have had an interest in the
structure of language. In order to begin with my little program, I need to
be able to take a string like "The dog jumped." and be able to take the
first word from the sentence and assign it to a string, such as word1,...
|
by: Sling |
last post by:
I code in Rexx on the mainframe which has 2 built-in functions: word(s,i) &
words(s).
word(s,i) returns the ith word in the s(tring), and words(s) returns the
number of words within the s(tring).
Is there something equivalent in C#, preferably built-in (assumed better
performance), or sample code?
Thanks in advance.
|
by: Steven |
last post by:
Hello,
I have a question about strcmp(). I have four words, who need to be
compared if it were two strings. I tried adding the comparison values
like '(strcmp(w1, w2) + strcmp(w3, w4))', where w1 and w2 make up the
first string and, w3 and w4 make up the second string. I do not want
to allocate memory, then put the words together to create a string
only to facilitate strcmp() comparison.
My question; Does anyone know how to get the...
| |
by: abraxas |
last post by:
Ok maybe someone here can help me. I have been learning c++ and have
been toying with some basic programming and have run into something
that I would have assumed would have been fairly easy. I am wanting to
input a list of words into the program and I thought you would use and
array to do that, but I am not having any luck finding info on storing
an actual list of words. I have set it up so that it prompts you for
the number of words. ...
|
by: dmurray14 |
last post by:
Hey guys,
I'm a C++ newbie here - I've messed with VB, but I mostly stick to web
languages, so I find C++ to be very confusing at times. Basically, I am
trying to import a text file, but I want to do it word by word. I am
confused as to how to do this. Typically, I would think it would make
sense to try and input the words into strings, but for this application
I need to use character arrays and pointers. So what's the best way to
go...
|
by: Xernoth |
last post by:
Hi,
I have an exercise that requests the following:
Write a function that reads words from an input stream and stores them
in a vector.
Use that function both to write programs that count the number of
words in the input,
and to count how many times each word occurred.
|
by: shapper |
last post by:
Hello,
I have a string and I need to get as many words possible counting from
the beginning but without exceeding 120 characters. I can't break
words and I the string shouldn't end with a comma, a dot, ...
How can I do this?
Thank You,
Miguel
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |