File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes parseInt method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "parseInt method" Watch "parseInt method" New topic
Author

parseInt method

Gina vernon
Ranch Hand

Joined: Jan 16, 2009
Posts: 108
Hi,
I have the following code that does not run when I use the parseInt method:



Am I using the method right?

Thanks.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
indexOf returns a number, so why are you using parseInt to start with?

Eric
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Regular Expression may be easier:



Eric
Gina vernon
Ranch Hand

Joined: Jan 16, 2009
Posts: 108
Eric,
Thanks for the reply. I am not sure if reg exps are right for my requirement. The string that I am searching looks like this 'xyz - 34534, y.5'.
I need to fetch the integer between the hyphen and the comma. This integer is of variable length. The only things that remain constant in this string are the hyphen and comma.

Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60059
    
  65

That sounds like a textbook case for a regular expression.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Only thing you would need to change is



and



The regular expression will yank it out for you. Test it out!

Eric
Gina vernon
Ranch Hand

Joined: Jan 16, 2009
Posts: 108
Eric,
Thanks! I didn't check the thread and I found that this works too:

Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
I would just be careful with the look ahead since IE can be buggy with it. I am not sure if older versions of IE support it.

Eric
Gina vernon
Ranch Hand

Joined: Jan 16, 2009
Posts: 108
Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: parseInt method
 
Similar Threads
Date - calulate new to x number of months?
howto format number ?
String date in to Date type
How to pass a javascript variable on a jsp to a servlet
Need Help With Dynamic text box in JSP