last day (15 days later) » 

4:42 PM
1
A: Removing all the non-letters and punctuations from a String

Sireesh YarlagaddaTry this String val="The red; fox is hungry!!! but, is he angry? doesn't! (yeah!). Call 911!"; val = val.replaceAll("[^a-zA-Z_]", " "); For ignoring single quotes, try this. val = val.replaceAll("[^a-zA-Z_\\']", " ");

 
@donfuxx OP has a problem all together that he really wants to implement a whole dictionary but has decided against it for now.
 
i had edited the code for fixing the issue (val = val.replaceAll("[^a-zA-Z_\\']", " ");). Issue Fixed. @donfuxx .
@CodeCamper, it work as expected now.
 
@SireeshYarlagadda What does it do?
 
@GloryOfSucess - Try the second solution, it will work as 'Should be' String
@CodeCamper Added the \\' for ignoring the single quotes. :)
 
@SireeshYarlagadda it will keep the single quotes even if they are sitting by themselves in the middle of the sentence? I believe the OP only wanted single quotes if they were part of an English word...
 
4:43 PM
@CodeCamper - its all about the regex expression
but not checking the workd against dictionary.
 
Does it just retain all the '?
For example if the input was 911'''''''
 
single quotes are excluded.
while replacing
with the current regex
it matches to the desired string as per the user - question
 
Why do you add \\?
 
i have added \\'
 
but why the double \ doesn't that also omit the \s?
 

last day (15 days later) »