473,396 Members | 1,590 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,396 software developers and data experts.

words in strings

Hello;

How can I count number of word in strings, and how to find out if
some word exceed number of characters (if this happen table layout is
ruined on web page).

Any clue how C# do this?

Thank you

Jul 24 '07 #1
3 1326
"Aahz" <ju*******@hotmail.comwrote in message
news:11**********************@d55g2000hsg.googlegr oups.com...
How can I count number of word in strings,
Split the string on the space character...
http://msdn2.microsoft.com/en-us/library/b873y76a.aspx
and how to find out if some word exceed number of characters
Loop through the array returned by the Split method:

string strRaw = "This is a string with some words and spaces";
string[] strWords = strRaw.Split(' ');
foreach (string strWord in strWords)
{
if (strWord.Length 10)
{
// do something
}
}
(if this happen table layout is ruined on web page).
Presumably you're using a fixed-space font? If not, counting the number of
letters won't give you a particularly accurate value for how much screen
real estate the word will occupy...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 24 '07 #2

"Aahz" <ju*******@hotmail.comwrote in message
news:11**********************@d55g2000hsg.googlegr oups.com...
Hello;

How can I count number of word in strings, and how to find out if
some word exceed number of characters (if this happen table layout is
ruined on web page).
Maybe you just want to set the "overflow" CSS attribute?
>
Any clue how C# do this?

Thank you

Jul 24 '07 #3
The Web isn't WSYIWYG. Most Web developers accept the fact that they do not
have absolute control (or even "very much control") over the final
appearance of their Web pages. NO matter how carefully you structure your
Web pages, CSS and whatnot, the user can always change browser settings that
will screw up your intended layout. Even if the user doesn't change browser
settings, different browsers and different versions of browsers interpret
the various Web standards differently and therefore render HTML in different
ways. Consider, for example, the Box model and the various hacks being
promoted for those Web developers who need to work around the different
browser implementations of it.

"Aahz" <ju*******@hotmail.comwrote in message
news:11**********************@d55g2000hsg.googlegr oups.com...
Hello;

How can I count number of word in strings, and how to find out if
some word exceed number of characters (if this happen table layout is
ruined on web page).

Any clue how C# do this?

Thank you

Jul 24 '07 #4

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

Similar topics

31
by: Brynn | last post by:
I want to thank the person that sent the nasty messages to my contact.asp test page ... you have inspired me !!! I have now added a bad_words filter both to my JSValidation script (going up on...
5
by: Paula | last post by:
Hi !! I have to find some words in a string. I can use string.IndexOf, LastIndexOf, etc, but they are case sensitive. And there is another problem : If I found the word, I have to get three...
7
by: Timo Haberkern | last post by:
Hi there, i have some troubles with my TSearch2 Installation. I have done this installation as described in http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_compound_words...
7
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)....
9
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...
7
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...
3
by: Csaba Gabor | last post by:
I'm comparing the text of (snippets of) web pages which I expect to be quite different or quite similar. In the case where they are similar, I would like to display the more recent one and say...
10
by: pantagruel | last post by:
Hi, I'm looking for an optimal javascript function to split a camelcase string and return an array. I suppose one could loop through the string, check if character is uppercase and start...
20
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...
10
by: Robert R. | last post by:
Hello, i would like to write a piece of code to help me to align some sequence of words and suggest me the ordered common subwords of them s0 = "this is an example of a thing i would like to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
marktang
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,...
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...
0
Oralloy
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,...
0
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...
0
agi2029
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,...

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.