Note that there are some explanatory texts on larger screens.

plurals
  1. POJava String formatting solution
    text
    copied!<p>I have a string description of a company, which is nasty written by different users (hand-typed). Here is a example (focus on the dots, spaces, first letters etc..): </p> <blockquote> <p>XXXX is a Global menagement consulting,Technology services and outsourcing company, with 257000people serving clients in more than 120 countries.. combining unparalleled experience, comprehensive capabilities across all industries and business functions,and extensive research on the worlds most successfull companies, XXXX collaborates with clients to help them become high-performance businesses and governments., the company generated net revenues of US$27.9 Billion for the fiscal year ended 31.07.2012..</p> </blockquote> <p>Now what i want is to format the string to a bit nicer version like this:</p> <blockquote> <p>XXXX is a global management consulting, technology services and outsourcing company, with 257,000 people serving clients in more than 120 countries. Combining unparalleled experience, comprehensive capabilities across all industries and business functions, and extensive research on the world’s most successful companies, XXXX collaborates with clients to help them become high-performance businesses and governments. The company generated net revenues of US$27.9 billion for the fiscal year ended Aug. 31, 2012.</p> </blockquote> <p>My question is: Is there any library with already defined methods which could do all the spelling corrections, unneeded space removal, etc .. ?</p> <p>So far, I do it be replacing stuff like " ," with ", " and toUpperCase() if the is a "///." in front etc..</p> <pre><code>desc = desc.replace(" ", " "); desc = desc.replace("..", "."); desc = desc.replace(" .", "."); desc = desc.replace(" ,", ", "); desc = desc.replace(".,", "."); desc = desc.replace(",.", "."); desc = desc.replace(", .", "."); desc = desc.replace("*", ""); </code></pre> <p>I'm sure there is a cleaner and better version to do this. Using regex maybe?? </p> <p>Any solution would be appreciated.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload