Count word without space in C#

Dear sir,
I would like to count word in sentence without space in c# but I could not solve this code.Please solve this one coding is below
            int i = 0,b=0;
            int Count2 = 1;
            for (i = 0; i < Paragraph.Length; i++)
                if (Paragraph[i] == ' ')
                    for (b = i; b < Paragraph.Length; b++)
                        if (Paragraph[b] != ' ' && Paragraph[b] != '\t')
                            Count2++;
                            break;
            Console.WriteLine("Total Word = {0} .", Count2);

Dear Sir,
I want to count words without space in a Sentence but I face a problem that when I run the program space is also count with words but I want count only words Please guide . My C#  program is as under .
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.IO;
namespace Static_Method_Count_Word
    class Program
        static void Main(string[] args)
            Console.WriteLine("Please Enter Any Paragraph .");
            string Paragraph = Console.ReadLine();
            Count.Coun(Paragraph);
            Console.ReadLine();
    class Count
        public static void Coun(string Paragraph )
            int i = 0,b=0;
            int Count2 = 1;
            for (i = 0; i < Paragraph.Length; i++)
                if (Paragraph[i] == ' ')
                    for (b = i; b < Paragraph.Length; b++)
                        if (Paragraph[b] != ' ' && Paragraph[b] != '\t')
                            Count2++;
                            break;
            Console.WriteLine("Total Word = {0} .", Count2);

Similar Messages

  • Deliver individual words without spaces or punctuations

    I want to find the first alphabet in each word. So it is more convenient to use StringTokenizer to deliver individual words one at a time. But I also want to eliminate the whitespaces and all punctuations that might be at the start or the end of a word.For example:
    String phrase = "Documen-
    tation is i-
    mportant."
    So if the last token in a line ends with "-", then don't include the first letter of the first token on the next line in the count.
    I used StringTokenizer st = new StringTokenizer(phrase, "-."); , but it was not working, can anyone help me?

    while((line = in.readLine())!=null)
                                       words = new StringTokenizer(line);
                                       for (int i = 0; i<words.countTokens(); ++i){
                                            while(words.hasMoreTokens())
                                                 word = words.nextToken();
                                                 word = word.toUpperCase();
                                                 ch = word.charAt(0);
                                                 if(ch >= 'A' && ch <= 'Z'){
                                                      int inx = (int)ch - (int)'A' ;
                                                      charCount[inx]++ ;
                                                      total++;
                                  }I am actually counting the initial letter of each word, so I don't want to include any punctuation in between a word

  • I just updated pages, I can't count the amount of words with space anymore. Can anybody help me?

    I just updated pages, I can't count the amount of words with space anymore. Can anybody help me?

    Yes me too, tried re setting and enabling changes but no agree button anywhere?

  • Counting words in a single cell in Numbers'09

    Hi there,
    I'm relatively new to Mac world, but I do have years of computer experience from a PC and have also had to do with Macs at the age of first eMacs . I have finally decided to switch to the brighter side of life (hopefully ;)).
    But here is my question: I need to count words in a cell in Numbers'09.
    Is there a specific function combination for achieving this? My idea was: strip excessive spaces, count the occurencies of all space character in a cell, add 1 and voila! Problem is I can not achieve it using formulas in Numbers'09. I have found some help for Excell but the formulas are a little different. And well, I would like to leave the past behind and stick to a Apple programs - if I can. I don't like the idea to install Excell on a Windows Bootcamp partion only for this purpose.
    Any help would be greatly appreciated. Thanks.
    Aleksander

    Badunit wrote:
    Yvan once had a list of all the different localizations. He may still have it.
    I'm late but, I was very busy
    The table with every localized functions names is (and will remain) available on my iDisk :
    <http://public.me.com/koenigyvan>
    Download :
    For_iWork:iWork '09:functionsNames.numbers.zip
    An easy soluce for foreign users (like me) is to duplicate Numbers.app and remove its languages resources minus English.
    Running it you will have it running in English (minus the decimal and the parameters separators, minus also date time formats and default currency).
    It would be easy to enter the formulas given in this forum.
    Once saved, we may open the doc in the 'standard' Numbers and the formulas will be automatically localized.
    Yvan KOENIG (VALLAURIS, France) mardi 2 mars 2010 18:30:45

  • How to count words in a PDF file?

    Is there any way I can count words in a PDF file without resorting to Acrobat Reader (which apparently has that feature)?
    That's a massive program, which I actually don't like.
    I need to count words in the PDF file because I write my papers with LaTeX, and they're full of my extensive comments.
    Do you know of any alternative?

    that utility IIRC cannot be found on xpdf (the official Archlinux package) anymore and its part of poppler
    edit: its pdftotext btw
    Last edited by dolby (2008-05-11 13:35:05)

  • Counting words in a textArea

    Help !!
    I am trying to count the number of words contained in a text area - Is it possible to do this ?
    I am new to Java and I'm stuck because I only know how to write programs that use FileReader to count the number of words in a file.
    Is it possible to count the number of words in a string directly - or will I have to save the string to file and then apply another program to count the number of words ?

    You inser this code in your source file (TextArea1 is the name of the TextArea, whose you want to count words)
    String texte=TextArea1.getText();
    String rt=String.valueOf((char)13) + String.valueOf((char)10);
    StringTokenizer mots=new StringTokenizer(texte," ,.:;!?\t"+rt);
    int nbremots=mots.countTokens();
    and you place at the header of the file
    import java.util.StringTokenizer;
    nbremots is the number of words The delimitors between words are noticed in the second argument of the constructor of class StringTokenizer. I have choosen the main signes of punctuation like space, coma,stop... the String rt
    symbolise return on Windows. If you work on Unix prefer this code
    String texte=TextArea1.getText();
    StringTokenizer mots=new StringTokenizer(texte," ,.:;!?\t\n");
    int nbremots=mots.countTokens();
    You can also with the class StringTokenizer read the words one by one with this type of boucle
    while (mots.hasMoreTokens())
    String mot=mots.nextToken();
    mots.nextToken();
    It is an useful class. See the API about this class StringTokenizer in the package java.util

  • Change the background color of a particular word without changing the background color of the rest of the text in a textbox

    Hello,
    I'm designing my own website and want to know how to change the background color of a particular word without changing the background color of the rest of the text in a textbox. If i can't do this, how can I create a Table, similar to Excel with iWeb?
    Thank you very much!
    Roger.

    If i can't do this, how can I create a Table, similar to Excel with iWeb?
    Read this :
         Create and add a TABLE in iWeb »
         More about a TABLE in iWeb »
         Sample 1
         Sample 2

  • How can I load pics from camera without spaces in the filename (PSE5)

    Hello,
    I want to load the pics from my Fuji Camera with my newly acquired Photoshop Elements 5 into its database as simple as possible. I get offered several ways of renaming the pics during the import. Unfortunately the date formats offered (for folder or filenames) do *all* include space characters " ", which I do not like, because this caused me earlier a lot of trouble when putting the pics online, for example (%20 in the path name). Another reason is my existing photo collection since 2001, which has no spaces in the filenames as well.
    Example for the filename:
    PSE offers: "jj mm dd 001.jpg"
    I want : "jjmmdd_001.jpg" or at least "jj_mm_dd_001.jpg" or anything similar.
    For folder names the same thing appears.
    Is there a way to do that without typing each date without spaces by hand?
    How?
    I would like to have the photo load process as simple as possible, without having to remove the spaces with a separate rename tool.
    Any ideas?
    I searched for quite a while and I am surprised that nobody else seems to have this problem. Am I just too picky?
    Thank for any help.
    Greetings from Germany,
    Ulrich

    Ken,<br />again thanks for your writing.<br /><br />IMHO, if PSE had space free filenames, this would lead to a very simple and fast workflow with PSE alone (!) like this:<br /><br />1. Just connect my camera (Fuji F31fd) with the USB cable (no fiddling with the memory card in and out each time)<br />2. Transferring all (or selected) pics into PSE, one folder per day, named yymmdd_optional_theme_description.<br />3. Delete all non-optimal pics after viewing in PSE. Then tagging, pic-improving where needed ....<br />4. As backup, burn/move to CD from time to time and copy/move to an external HDD for double security.<br /><br />Its just the spaces in the filenames which prevents me from using this. I want to have the workflow well defined and fixed before I start using PSE5. <br />But it seems there is no workaround (so far).<br /><br />Maybe I should just take the "trouble" and rename every folder manually within PSE. No problem with one or 2 days, and still not a very big problem after a 3 week holiday. But still all single photo files will have the spaces in them. If I want to avoid that, I really have to bring them to the PC without PSE, rename them as batch with Irfan or any other tool, and then import them to PSE, as you wrote. From my point of view, a lot of unnecessary hassle, especially if I have the simple workflow from above in mind.<br /><br />Many people seem not to be disturbed by the spaces in the filenames. I wonder if I overrate the disadvantage of it. Your opinion(s)?<br /><br />I am not sure what you mean with<br /><Perhaps Ulrich would be well served if he created a collection of newly acquired pictures with a common theme.><br /><br />In fact I want to come away from theme centered archiving the photos, which is what I did so far. I learned this from the article <br />http://forums.dpreview.com/forums/read.asp?forum=1018&message=26366116 <br />and the following one from Arrowman. I won't follow all what he wrote *in detail*, but most ideas seem to be good. The PSE tagging should do the theme-related searches.<br /><br />Greetings,<br />Ulrich

  • Count words in each sentece in a file

    Hi all
    i want to ask how can i count words in each sentece in a file??
    ie if i have the follwoing sentece
    i ate the cake.
    today is Sundy.
    i went to school 5 day a week.
    to have the number as
    4
    3
    8
    any ideas??

    you could read the file line per line, put the line
    in a string and use StringTokenizer to split it into
    word and count them. Or you could read file char per
    char, increasing the word counter everytime you find
    a blank char, when the read char is a newline you
    save the old counter and start a new word count for
    the new line.That's an option, but a sentence is not ended by a newline. A sentence ends with a full stop/point.
    Kaj

  • Deleting word deletes space before it as well

    I don't know if this has always been the case, but I've only just started to notice it and it is frustrating the **** out of me.
    In pages on the iphone and iPad, if I delete all the letters in the word, the space before the word automatically gets deleted as well.
    Try it.
    I just went to the apple store and it's happening on their ipads as well.
    I type for a living and cannot tell you how many thousands of times today I had to go back and correct words that had no space between them.
    Did someone really think that when I press delete once what I actually want is to delete twice?!
    So, anyone know if there's a way around this issue? I'm wondering if it came in with ios 7? Interestingly it's only pages, not happening on notes or email etc.

    For tips on how to get around it go here:
    https://discussions.apple.com/message/23253948?ac_cid=tw123456#23253948
    Either type with an X in front of where you're typing, or turn on tracking and set to "final" in settings.
    Best we have for now!

  • NULL option of column command - ignore word after space in string

    Hi,
    I'm quit new to Oracle and SQL world.
    building simple SQL/Plus report through SQL Developer enviroment:
    I'm trying to use NULL option of COLUMN comand to output a meaningful string instead null.
    But, any word after space in string.
    Followings are what I wrote on worksheet and excute 'Run Script'.
    COLUMN firedate NULL 'active';
    COLUMN mentorid NULL 'no mentor';
    select lastname, firstname, mentorid, firedate from members;
    refer to line (COLUMN mentorid NULL 'no mentor';) the out put for the MentorId, display word no and ignore any word after space which is here word mentor.
    My environment:
    SqL Developer ver. 3.1.07.
    Oracle database 10g Express edition (10.2.0.1.0)
    windows XP
    Much appreciated.

    SQL Developer is still not 100% SQL Plus compatible. It may be that this isn't implemented properly yet.
    Does it work in SQL Plus?

  • Can we create a Portal without Spaces using JDeveloper ?

    Hi
    Is it possible to have Portal without Webcenter Spaces (collaboration) component for WebCenter but I do require a portal with the Administration functionality found in the WL_Spaces managed Server. For instance, securing pages/portlets, LDAP/OAM integration, exchange integration, UCM integration, configuration with WSRP portlets on WL_Portlet and analytics configuration with WL_Utiltiies. Can we create a new portal (one without Spaces) using JDeveloper and create a managed server?
    Cheers
    Khad

    Yes you can!
    WebCenter is more than just WebCenter Spaces.
    WebCenter Spaces is just one part, another part is the WebCenter Portal which is an application in JDeveloper. You might want to read my tutorial: http://www.yonaweb.be/webcenter_tutorial/introduction it explains how to build such a portal.
    All the connections you make in the enterprise manager, can also be configured in JDeveloper so you can also use UCM, mail server, portlets and so on in WebCenter Portal application in JDeveloper.
    It is common practice to create a new managed server on your domain to deploy the custom WebCenter Portal application. You can also manage the connections to the different service from within the enterprise manager, just as you do with spaces.

  • Cheque amount to word with space inbetween

    Hi All
    Has anyone come across printing cheque amount to WORD with space inbetween the word wrap to make the cheque look tidy.  
    Any help will be appreciate
    Raj

    Hi,
    Have you designed cheque through PLD or CR.
    regds,
    sampath.

  • Is there a method for counting words?

    Hi!
    Is there a method for counting words?
    How do I read specific data ( row, column ) out of an array?
    Thx
    Lebite

    There's could be a better way, but this is how I would do it:
            String[][] myArray = { {"Blah Blah Blah"},
                                   {"Blah Blah Blah"},
                                   {"Blah Blah Blah"} };
            int tokens = 0;
            for(int i = 0; i < myArray.length; i++)
                for(int j = 0; j < myArray.length; j++)
    StringTokenizer st = new StringTokenizer(myArray[i][j]);
    tokens += st.countTokens();
    System.out.println(tokens);

  • HT4906 In my iphone, photo stream also counts in storage space but as per Apple Photo Stream does not occupy storage space. Any info on this pls.

    In my iphone, photo stream also counts in storage space but as per Apple Photo Stream does not occupy storage space. Any info on this pls.

    And
    Does this involve iPhoto in any way?
    LN

Maybe you are looking for