To trim a string value

Posted on 2004-10-13
Last Modified: 2010-04-01

I have a string value that can look somewhat like this:
or something like that.

What I want to do is, if there's a "." in the string, remove everything behind it. Ie. "410.13456" will become "410".

How do I do this the simplest way possible.

Question by:larsan
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 92

Accepted Solution

objects earned 500 total points
ID: 12296308
int dot = s.indexOf(".");
if (dot!=-1)
   s = s.substring(0, dot-1);
LVL 92

Expert Comment

ID: 12296313
or maybe:

s = s.split("\.")[0];

Author Comment

ID: 12296881
The first one works if you put it like this:



Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
tomcat users xml 7 139
maven project in eclipse 11 60
Reading data  from excel sheet and displaying 1 92
best tutorial on log4j and logging for servlets/jsp codes 1 65
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question