File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes find integer index  in string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "find integer index  in string" Watch "find integer index  in string" New topic
Author

find integer index in string

ramesh kancherla
Ranch Hand

Joined: May 01, 2008
Posts: 124
Hi,
This is Ramesh. I am parsing line of text from a string. I have to find a index of the word in a line.this word contains a number.

line of text is like as

AARON JOSEPH AUERBACH JUDITH A 25B PLAZA ST W APT 8M BROOKLYN NY

can any one please give me suggestion how do i find it.

Thanks & Regards
Ramesh K
Brij Garg
Ranch Hand

Joined: Apr 29, 2008
Posts: 234
You can use indexOf() methods ....

For more information you can google it or check java apis.
James Basller
Ranch Hand

Joined: Sep 07, 2008
Posts: 58
Originally posted by ramesh kancherla:
Hi,
This is Ramesh. I am parsing line of text from a string. I have to find a index of the word in a line.this word contains a number.

line of text is like as

AARON JOSEPH AUERBACH JUDITH A 25B PLAZA ST W APT 8M BROOKLYN NY

can any one please give me suggestion how do i find it.

Thanks & Regards
Ramesh K


Yes you can use indexOf() method by passing string parameter that you need to find. But for that the search text should be constant means if as per your given line you can pass indexOf("25B"). then in all lines it will find position of 25B
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39393
    
  28
Sounds like a beginner's question. Sounds like a job for regular expressions.
ramesh kancherla
Ranch Hand

Joined: May 01, 2008
Posts: 124
hi,
I know indexOf method. But I am taking address from list addresses. so 25B will change in another address.

so how can I find index of the word , it contains number.

can any one please give me suggestion

Thanks & Regards
Ramesh K
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39393
    
  28
Originally posted by myself:
Sounds like a beginner's question. Sounds like a job for regular expressions.
Like that.
ramesh kancherla
Ranch Hand

Joined: May 01, 2008
Posts: 124
HI,
how do i write regular expression for the word contains number

can any one please give me suggestion

Thanks & Regards
Ramesh k
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39393
    
  28
Rob: suggest you move this thread, please.

Ramesh: have you read the tutorial link I posted?
ramesh kancherla
Ranch Hand

Joined: May 01, 2008
Posts: 124
HI Campbell Ritchie ,

I understand how do write regular expression starting with numbers or starting with alphabets.
but i have to find word, containing number . the number position is any position in word. is it possible with regular expression.
if yes please tell me

Thanks & Regards
Ramesh K
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39393
    
  28
Yes, of course you can create a regular expression for letters-numbers. Have you read the tutorial link?
ramesh kancherla
Ranch Hand

Joined: May 01, 2008
Posts: 124
Hi Campbell Ritchie ,

yes i have read tutorial. I can write sequence of integers and characters.

but how can I find that numbers with characters not sequence

can you please tell me.

Thanks & Regards
Ramesh K
[ September 10, 2008: Message edited by: ramesh kancherla ]
ram kumar
Ranch Hand

Joined: May 22, 2008
Posts: 146
Originally posted by ramesh kancherla:
Hi Campbell Ritchie ,

yes i have read tutorial. I can write sequence of integers and characters.

but how can I find that numbers with characters not sequence

can you please tell me.

Thanks & Regards
Ramesh K

[ September 10, 2008: Message edited by: ramesh kancherla ]


Hey Ramesh,

I will give you a free code that i was doing once long back for extracting int's from a string.



This Should help you solving the problem ! Its just a BaseLine from which you can customize what you want !

This code will get all integers from the String that you supplied.

What ever format that you need to get it is upto your design and customization !






Discussion - the powerfull way to excellence!
ram kumar
Ranch Hand

Joined: May 22, 2008
Posts: 146
Originally posted by ram kumar:


Hey Ramesh,

I will give you a free code that i was doing once long back for extracting int's from a string.



This Should help you solving the problem ! Its just a BaseLine from which you can customize what you want !

This code will get all integers from the String that you supplied.

What ever format that you need to get it is upto your design and customization !







But Using Regular expresion is the best practice ever !



Try them !
ram kumar
Ranch Hand

Joined: May 22, 2008
Posts: 146
Originally posted by ramesh kancherla:
Hi,
This is Ramesh. I am parsing line of text from a string. I have to find a index of the word in a line.this word contains a number.

line of text is like as

AARON JOSEPH AUERBACH JUDITH A 25B PLAZA ST W APT 8M BROOKLYN NY

can any one please give me suggestion how do i find it.

Thanks & Regards
Ramesh K



ramesh kancherla
Ranch Hand

Joined: May 01, 2008
Posts: 124
Hi
It is working fine. Thanks for your help.

Thanks & Regards
Ramesh k
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: find integer index in string