Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2005

Tip: Looking for answers? Try searching our database.

parse int from string

Thread view: 
J M - 28 Apr 2005 01:50 GMT
How do I go about parsing integers from following form?

(a:3, b:4) (b:4, c:2) (c:2, d9) ... and so on

If I can I like to process two ints at a time for example 3 and 4 then move
on to 4 and 2 and so on...

TIA!
Abrasive Sponge - 28 Apr 2005 03:13 GMT
> How do I go about parsing integers from following form?
>
[quoted text clipped - 4 lines]
>
> TIA!

public void bushSucks(String s, Hashtable h) {
    int index = s.indexOf(':');
    String letter = "" + s.charAt(index-1);
    int number = Integer.parseInt("" + s.charAt(index+1));
    h.put(letter, number);
    woot(s.substring(s.indexOf(')')) + 1, s.length(), h);
}

eh, somephin like that I guess.  Not the best solution, but since I am
assuming you are a student. It would be best for you to find a better way.

:)
PaulR - 28 Apr 2005 11:11 GMT
I'm sure you could do something with regular expressions here.

Something like "\(.*?\)" to get the bracketed groups. Then "\d" to get
the digit groups.
PaulR - 28 Apr 2005 11:12 GMT
I'm sure you could do something with regular expressions here.

Something like "\(.*?\)" to get the bracketed groups. Then "\d" to get
the digit groups.
Betty - 29 Apr 2005 23:24 GMT
> > How do I go about parsing integers from following form?
> >
[quoted text clipped - 12 lines]
> woot(s.substring(s.indexOf(')')) + 1, s.length(), h);
> }

Is the "d9" part a typo? Should it be "d:9"?


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.