Removing punctuation from the beginning and end of a string

I am working on a project for a "spell checking" program. So far the StringHash class is made, and the dictionary is read into a hash table. Then the document to be checked is specified via command line, the document scans through each word and checks to see if it is in the dictionary, if it is do nothing, if it is not then display it to console. The problem I am having is with a method in the main class. The method (I will post what I have so far) is called removePunct. The method should remove any punctuation from the beginning and the end of the string, nothing from the middle. Here is what I have so far:
public static String removePunct(String word){
          StringBuilder wo = new StringBuilder(word);
          int x = (word.length()-1);
          if(!Character.isLetter(wo.charAt(0)))
               wo.deleteCharAt(0);
          if(!Character.isLetter(wo.charAt(x)))
               wo.deleteCharAt(x);
          return wo.toString();
Any help would be much appreciated, I'm pretty certain the solution is either something completely different, or something so simple that I just missed it.

The easiest way to do this is to just show you the actual file to be spell checked:
-- outline --
This directory contains Bison skeletons: the general shapes of the
different parser kinds, that are specialized for specific grammars by
the bison program.
Currently, there are only three supported skeletons:
- yacc.c
It used to be named bison.simple: it corresponds to C Yacc
compatible LALR(1) parsers.
- lalr1.cc
Produces a C++ parser class. It is still very experimental, and not
yet supported. Please, subscribe to [email protected].
- glr.c
A Generalized LR C parser based on Bison's LALR(1) tables.
These skeletons are the only ones supported by the Bison team.
Because the interface between skeletons and the bison program is not
finished, we are not bound to it. In particular, Bison is not
mature enough for us to consider that ``foreign skeletons'' are
supported.
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Bison.
GNU Bison is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Bison is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Bison; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
What I need the spell checker to do is read each word, and strip any beginning or ending punctuation, e.g. (c) would become c. Pretty much punctuation consists of anything that is not a letter, hence the use of isLetter. I can easily modify the method to remove all punctuation using regular expressions, but I only want the beginning and end characters removed.
Example of words:
-yacc.c would become yacc.c and is not in the dictionary so it would be printed.

Similar Messages

  • How do I remove residual frames at the beginning and end of a video?

    I'm making a short clip with black slugs at the beginning and end. But there are two or three residual frames from the incoming clip after the black clip that stay at the beginning and end of the video and I can't remove them.  I've tried trimming the beginning and end of the video several different ways, and the frames won't disappear. They stay in the video when I make a DVD. The very first and very last frame have sprocket holes in them on the edge of the frame. I'm baffled. Is this an artifact of using the trial version?

    chances are they are from a fade.  have you zoomed in really really close and checked if there is a small fade in or fade out?  happens to me all the time, and with the fade out, you can't do anything to fix it (that I've found) except replacing the clip from your Browser.  See my similar question here:
    https://discussions.apple.com/thread/3589714
    Hope that helps.

  • How can I put asterisk in the beginning and end of a search parameter..?

    Hi!
         I'm developing a program for a user where he wants a search parameter for the description about some purchase orders....
    The problem is if the user want to make a search for any word he need to put asterisk in the beginning and end of the word because if the user don't put the asterisk the search will not find anything because the program don't know if the word is in the beginning of the description or in the end or in the middle...
    How can I put one asterisk in the beginning and end of the search topic entered by the user internally in the program..? I was thinking using the concatenate function but for this will not work because the program think that the asterisk is part of the word and not..
    The search parameter of the Description is in range.. (Select-Options).
    Thanks for your help!!

    Thanks keshav!
    OK... and if I concatenate the asterisk latter I can make this search?
    In the code desc_search is the select_option that I tell u. I use the DESCRIBE to see first if it is not initial... if desc_search have an entry then access the DELETE to remove all the records that are diferent from desc_search.. This desc_search will have the word with the asterisk... and the question is if it works if I use the concatenate before this... anyway I will try but I think that if I use the concatenate the program confuse and take the asterisk as part of the word..
    DESCRIBE TABLE desc_search LINES desc_count.
      IF desc_count IS NOT INITIAL.
        DELETE core_table WHERE desc NOT IN desc_search.
      ENDIF.
    Let u know if works!!
    Thanks!

  • TS1367 my laptop will not boot up from the storage hard drive but if i remove it from the laptop and connect it as portable hard drive my laptop boot up normal?

    my laptop will not boot up from the storage hard drive but if i remove it from the laptop and connect it as portable hard drive my laptop boot up normal?

    Do you have a compatible OSX installed on this 'storage' HDD?  If not, it will not boot your MBP.
    Ciao.

  • Some songs starts on my iPod, then stop and start from the begining and play all the way through

    Hey,
    While listening to songs on my iPod Classic 120gb, some songs will start to play, after 2-3 seconds, stop and start again from the beginning and play through the entire song no problems. On iTunes the songs still plays fine no stopping or starting. All songs are random artists and songs.
    Help! its really frustrating!

    Hey andy8299,
    Do you have any other music software (i.e Limewire) installed? If so perhaps these files are not compatible.
    See this for compatible song formats:
    http://docs.info.apple.com/article.html?artnum=61476
    Hope this helps,
    Generik

  • Can you adjust audio volume at the beginning and end of a clip?

    I want to add portions of songs into my iMovie videos. When I do that they abruptly start and end. Is there no way to adjust add a fade at the beginning and end of an audio clip?

    As said above, you cannot.
    The only work around is to edit audio in an external app.
    So please do suggest to Apple to add this feature in the next update.
    http://www.apple.com/feedback/imovie_iOS.html

  • How to calc the begining and end of every month (leap year)

    Hi all,
    I'm looking for a method that returns the begining and end of next month.
    example:
    today is 2005-10-04
    so the method suppose to return:
    2005-11-01
    2005-11-31 //as it ends on the 31
    I came up with the code below - but I don't like it as I can't get the end of month + it's not safe.
    any suggestions.
    Thanks
    Peter
    Calendar gcToday = Calendar.getInstance();
              int month = gcToday.get(Calendar.MONTH);
              int year  = gcToday.get(Calendar.YEAR);
              month+=2;
              if(month>12) //beacuase of month+=2;
                   year++;
                   month=1;
              String nextMonth;
              if (month<10)                         
                   nextMonth=year+"-0"+month+"-01";
              else
                   nextMonth=year+"-"+month+"-01"; 

    Look at using the methods getActualMaximum() and getActualMinimum() in the Calendar class. Basically what I would do is set the calendar to the 15th of the month (well, really anything between 1 and 28) and then add() one to the current month. The Calendar will roll over the dates as needed.

  • Playbook requires me to pay for support when it did not work from the beginning and they could not fix.

    lack of email app- makes this may purchase virtually useless. because
    cant bridge with my bb 9700. maybe twice after deleting from both, and rebridging, i got connections. i cant spend an hour bridging every time. since may this is unfixable. the support people cant fix it after dozens of hours. got lots.of emails from them though. asking if i was resolved. when i answered no, they asked me to do it all again. they have no fix for this.
    can type documents, but cant email them to anybody. same with excel. no way to attach documents when the bridge doesnt work.
    i am a ceo,and i am moving my entire organization off bb becuase of this.
    have spent many many hours from the beginning in may, and now they want me to pay a 129 dollar fee to get support when it has not worked right from the beginning.
    i bought an ipad today and i am absolutely blown away by how much better it is in every single way. dozens of bbs are going away now.
    slow, no.email, locks up all the time, stand by button restarts tablet, no bridging without total reload on both devices. why would i go through this anymore? it is costing my business a fortune with myself and my people trying to make the playbook work.
    we will get ipads and make more money.
    i have tried to stay loyal to bb, but after being told i have to pay for support
    when i did once get a connection through bridge, reply locked up everytime on an email. could not type.

    I would like to add my support to this comment.
    Strike 1) Bridging a BB 9700 with a PB is flaky at best. Even if you run the very latest software on both, it does not work properly. This is NOT a user issue but a programme/application issue. RIM software running on RIM hardware and O/S and NOT being able to connect properly = RIM fault.(see my other post: My Bridge connects, it exchanges data like passwords, number of unread emails and my playbook notifies me when someone calls my BB, but it does NOT unlock)
    Strike 2) All this used to work fine during the 90d grace suport period (apart from the flaky bluetooth issue that required a hard reboot of the BB whenever the connection was broken in a bad way)
    Strike 3) Now, after a PB OS upgrade (which I faithfully applied), several phone upgrades (due to another problem) and the latest Bridge application install, it all doesn't work anymore, 100 days after I bought the flipping thing. so I have a fancy ebook reader, not the productivity enhancing tool I can use on the go.
    So now I am stuck with a forum that can't help, a technical database that does not contain this support information and a broken RIM application on RIM Hardware and O/S that I paid a lot of money for. And now they want more to look at this incident????? I am sorry but if this was a problem caused by usage, configuration or any other user error, I could understand it. But this is all completely in RIMs ballpark. I have done everything right. It connects. It just DOES NOT WORK!!!!!
    As I said in my other post, an evaluation of the PB in my company is ongoing as a possible management tool by people I know quite well, as I work in the area, but my advice would definitely be to stay away until basic functionality like emails, attachments, calendars etcetera are all suitably solved and usable by the average manager with sausage fingers and no clue about bluetooth, hard reboots and who won't be able to hold down the power, + & - buttons at the same time as the fingers won't fit!!
    So RIM, get your finger out, open up an email support channel or get some qualified support people go through this forum and help those people who have shown faith in your products and who now have real problems with your software and hardware. DONT HIDE BEHIND A STUPID SUPPORT FEE - MAN UP TO YOUR PROBLEMS!!!

  • In Modified Preferences I have a URL that keeps coming up as a search engine. I have deinstalled it and removed it from the Tabs and History. How can i get rid of this?

    I accessed this site then decided it was not what I needed.
    I De-installed it by going to my control panel and removing it.
    I restarted my PC and it comes up as my home page. I deleted it from my History and recently visited sites. restarted my PC and it still comes up as the primary search engine as the opening page.

    I was trying to set up my home page using my web settings. That did not work.
    Set it up using foxfire. Works great.
    Thanks.

  • I use firefox but I do not want it in my dock. Can I remove it from the dock and still use it?

    I would like to keep firefox out of my dock so that customers do not click on it. Can I do this while I am still using it on another screen?

    I have Firefox open all the time. I use two screens, one is a large flatscreen tv that has surf reports and weather reports on it. So that customers to my store can see whats going on. I use Firefox for this. I have another screen that is computer size and I use this for internet patronage on Safari. The problem I have is people clicking on Firefox and messing up the weather and surf reports. I want then to only be able to identify Safari.
    Cheers

  • TS1702 Since I updated to ios6 my City of Warfare game shuts down when I try to go to battle. I removed my original game app and reinstalled a new game, which I had to start from the beginning and it still crashes. I'm sure that others are having similar

    Since I installed ios6 my City of Warfare game shuts down when I try to battle. I removed my original game and reinstalled a new game app which started a new game..and it still shuts down, help?

    Use the trackpad to scroll, thats what it was designed for. The scroll bars automatically disappear when not being used and will appear if you scroll up or down using the trackpad.
    This is a user-to-user forum and most people will post on here if they have problems. You very rarely get people posting to say there update went smooth. The fact is the vast majority of Mountain Lion users will not be experiencing any major problems with the OS, or maybe with apps which are not compatible, but thats hardly Apple's fault if developers don't update their apps.

  • How do I clean up the begining and ends of tracks?

    I can't seem to clean up tracks before committing them to disc.

    I can't seem to understand this question because it is so extremely vague.

  • How to add or remove silence at the beging and at end of each audio file using batch process

    Hi all,
    I am new to this forum. I have been using Audition 3 for the last couple of years and these days I have to coop with an extra difficult situation, which is; I have more than 2000 files that start and finish with a random length of silence, it varies 0 to 7 sec. My question is, how can I set the silent duration at the beginning and end of each file to a constant amount of 2 sec by using batch process?
    Kind regards,
    Pavlos

    >it's relatively easy to select an absolute time at the beginning of a file (we discovered how to do this a while back), the same technique simply doesn't work at all at the end of it
    Indeed! I had a few trials last couple of days and noticed it.
    Definitely we need help on Audition's scripting language from the people in Adobe. Why don't they produce a scripting language documentation?!   

  • TS1362 on my i phone the songs stop playing in the middle and skip sometimes and at other times the song stops and restarts playing from the beginning.  what is wrong

    on my iphone 4 the songs skip in the middle and also stop playing mid song and restart from the beginning and it happens over and over and the song never completely finishes.  I dont know what to do

    If your country's iTunes Store allows you to redownload purchased tracks, I'd delete your current copies of the dodgy tracks and try redownloading fresh copies. For instructions, see the following document:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    Otherwise, I'd report the problem to the iTunes Store.
    Log in to the Store. Click on "Account" in your Quick Links. When you're in your Account information screen, go down to Purchase History and click "See all".
    Find the items that are not playing properly. If you can't see "Report a Problem" next to the items, click the "Report a problem" button. Now click the "Report a Problem" links next to the items.

  • Find beginning and end of an XMLtag in text

    I am trying to find the beginning and end of an xml tag in a block of text using a script. Does anybody have any ideas on how to locate the beginning and end of an xml tag in text?
    You can see the ends of a tag visually from the user interface by the colored brackets that appear. So one of my ideas is to use a function to find the brackets. Does anyone know if those brackets have a character number, or some way to identify them?

    -257 is 0xFEFF (as a signed 2 byte word).
    I don't think that's a terribly reliable way of checking XML tags (I seem to remember this is more an internal "IsNotUsual" code for ID). And you don't know if it's a start or end tag.
    Your script may or may not pick up this code in the selected string, depending on where you start and end your selection. You can use regular string functions to remove them from the string.
    Perhaps it's better to walk over the XML tree and check if each element's start and end value ("storyOffset" for the start, a quick eyeballing of the help didn't reveal a good candidate for its end) is at the start and end of your selection.

Maybe you are looking for

  • External Link to Word document question

    Hello, fellow RoboHelpers! I have a quick question that I am hoping someone can answer for me. :-) I am using RoboHelp X5 and use Microsoft HTML Help (.CHM) as my file output. I would like to link a Word document to one of my topics, so when a user c

  • Delivery address replication from ECC to SRM

    Hello All We are onboarding a punch-out vendor in SRM. The Vendor said that they won't read the delivery address sent by us in the PO output, but would rather pre-store all the delivery addresses and their codes. The code would be auto read & this wa

  • ACR 4.4.1 does not open TIF file from bridge (CS3)

    Hi, I have the preferences in CS3-Bridge and ACR set to open JPG & TIF files in ACR and not CS3 but when I click on a TIF file in bridge it opens in PS CS3 instead. These TIF files were generated by a GUI interface for ENFUSE which is an algorythm th

  • Is 2gb of RAM enough for update to OS X Lion

    I have a Mid 2009 Macbook Pro with 2GB of RAM. I'm wondering if 2GB is enough to run Lion for my uses. I use microsoft office, iwork, and ilife regulary for school work and other purposes but nothing to extensive. Is 2GB enough? Thanks

  • Adobe Application Mgr

    I need to download all my application to a new comuter, can you send me the link to get the Adobe Application Manager. thank. DK