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

Similar Messages

  • 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);

  • 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

  • How do I change the font of individual words in a JTextArea?

    Hey everybody! I just have a quick question about JTextArea. I have a JTextArea and I am trying to find out how I can go about changing the style of individual words. For example, the first 3 words could be bold, and the next 3 words could be blue. How would I go about doing this? I know it is possible to change the entire font style of the whole JTextArea, but I am looking to change only individual segments at a time.
    JTextArea area = new JTextArea();
    area.setPreferredSize(new Dimension(320,380));
    area.setLineWrap(true);
    area.setWrapStyleWord(true);
    //code to change the first 3 words bold
    //and the next 3 words blue (as an example)
    //would go hereThanks so much!

    Try using HTML:
    Set the text to:
    area.setText("<html>My <b>Text</b> Here</html>");
    and see if the word Text is in bold. If so, then you can go as far as you want using HTML tags to set bold, color, etc.

  • 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?

  • 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!

  • Highlighting Search Strings vs Individual Words

    I am using the method on Peter Grainges site for Highlighting
    Search Strings. I have completed all necessary changes and the
    function works~~~~ One thing I have found that I wonder if I can
    change.... As it stands now If I enter more than 1 word to search
    ROBO actually separates both words and searches them as individual
    words ~ I want to search as a string not individually -- is there a
    fix for this?? Thanks in advance for any help that is
    offered.

    The search has no link to the highlighting in this context,
    it just makes it obvious.
    I don't think you can change that other than use a different
    search. ZoomSearch can be configured to work with RoboHelp and is
    described on my site.

  • 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.

  • How can I format individual words in a TabbedPanel2 tab?

    It seems that HTML tags are ignored in a SpryTabbedPanels2 tab. I know how to put a background image in via css, but I cannot then align the text to the bottom of the tab, so I cannot fake a large first word with an image. I would like to:
    1/ Be able to format individual words in the tab
    2/ Insert images anywhere in the tab (like you could in the old TabbedPanel)
    3/ Insert breaks <br> in the tab (like you could in the old TabbedPanel)
    4/ Align text within the tab.
    I realise there are four questions here, but they all seem very related to me and hopefully with have either one or four tightly related answers.
    Many thanks
    Jeremy

    You have probably also noticed that
    <div id="TabbedPanels2">
      <h2>Tab 1</h2>
    changes to
    <div class="TabbedPanels" id="TabbedPanels2">
        <div class="TabbedPanelsTabGroup">
        <div class="TabbedPanelsTab TabbedPanelsTabFirst PanelSelectorButtonUnselected">
          <a href="#">Tab 1</a>
        </div>
        <div class="TabbedPanelsTab PanelSelectorButtonUnselected">
            <a href="#">Tab 2</a>
        </div><div class="TabbedPanelsTab TabbedPanelsTabLast TabbedPanelsTabSelected">
            <a href="#">Tab 3</a>
        </div>
      </div>
      <div class="TabbedPanelsContentGroup">
          <div class="TabbedPanelsContent PanelHidden" style="display: none; ">
            <h2 style="display: none; ">Tab 1</h2>
    once it has been through the JS mill.
    My thoughts, although the original version may seem a little bloated, it is robust and easy to customise. Version 2 is slightly more agile and has a few more features, but is an ugly beast when it comes to customisation. In fact the two versions, apart from the Spry name, bear no resemblence to each other.
    I have stuck with the original version as I have done with the menubar.
    Gramps

  • In the compose field can't I color highlight chosen individual words??

    Using Thunderbird I'm dismayed that there appears to be no way to highlight individual words or phrases with a background color, as can be done in many email web interfaces on line, certainly those of AOL and Hotmail. All I find possible using Thunderbird is font color, not highlight.
    Is there no way to color highlight chosen words within the compose field using Thunderbird??

    Thunderbird comes as a basic email client. There are lots of add ons for all the fancy stuff people like to do.
    Install this add on. https://addons.mozilla.org/en-US/thunderbird/addon/highlighter-222207/?src=search

  • When trying to log in with my primary Apple ID and password, I am continuously asked for my pass word without being able to log in. How can I solve this issue, without creating a new Apple ID?

    When trying to log in with my primary Apple ID and password, I am continuously asked for my pass word without being able to log in. How can I solve this issue, without creating a new Apple ID?

    Chewning wrote:
    I saved some of my music to a Cloud I can't access. Now, they show up as "Purchased" in iTunes, and I'm not given the option of re-downloading OR repurchasing them.
    Music purchased from the iTunes store is not stored in your personal iCloud account, and an iCloud account is not required to redownload them.  You should be able to redownload them as explained here: http://support.apple.com/kb/ht2519.  If you are unable to, contact iTunes store support for assistance by going to https://expresslane.apple.com ; click ‘iTunes', and then 'iTunes Store', then 'Purchases, Billing & Redemption'.

  • How to bold individual word in a text caption??

    Hi,
    I'm pretty familiar with Captivate 5, though there doesn't seem to be a way to bold or underline an individual word in a text caption. This is a basic feature in most programs.
    I did search help and the forums for this. It sounds like you can either bold the text of the entire caption, though not a single word.
    Help please...
    If this functionality doesn't exist, Adobe needs to add it in the next release.
    Thanks,
    Dan

    Hi Dan
    Works for me. And it works like I would expect it to in Word or any other application.
    Select the text and press Ctrl+B to make it bold. Ctrl+U to make it underlined.
    Cheers... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

Maybe you are looking for

  • How to delete empty imported address books?

    I found similar issues but the solutions offered do not seem to work for me. I have now got 4 copies of implab.mab in my profile folder (suffixes -1, -2, -3). I've tried deleting the extra 3 with explorer but they reappear. I've tried renaming them a

  • How to enable SATA NCQ/AHCI in MacBook (Late 2007)

    I am planning to upgrade the HDD to a bigger SATA-2 model. I would like to ask does *MacBook (late 2007)* with *Mac OS X 10.5.2* natively support NCQ / AHCI ? Do I have to enter the BIOS to *enable the AHCI* function of the HDD?

  • Cinnamon Menu Text Size?

    I've found plenty of information concerning re sizing the panel, but is there any way to increase the text in the menu applet?

  • Problem in setting auto trace

    Hi, While setting autotrace i get the below error, SQL> grant all on plan_table to user; Grant succeeded SQL> grant plustrace to user; Grant succeeded connecting through the user i get this error SQL> set autotrace on; SP2-0613: Unable to verify PLAN

  • Downloading Raw Files on MAC

    Cannot download or find access to the plugin to allow download of raw files.  Adobe is worthless to me without this capability.  Where is the download for my MAC?