Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Removing characters from string after a certain point

843789Oct 24 2009 — edited Oct 24 2009
Im very new to java programming, so if this is a realy stupid question, please forgive me
I want to remove all the characters in my string that are after a certain character, such as a backslash. eg: if i have string called "myString" and it contains this:
109072\We Are The Champions\GEMINI
205305\We Are The Champions\Queen
4416\We Are The Champions\A Knight's Tale
a00022723\We Are The Champions\GREEN DAY
i would like to remove all the characters after the first slash (109072*\*We...) leaving the string as "109072"
the main problem is that the number of characters before and after is not the always the same, and there is often letters in the string i want, so it cant be separated by removing all letters and leaving the numbers

Is there any way that this can be done?
Thanks in advance for all help.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 21 2009
Added on Oct 24 2009
6 comments
1,632 views