• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

find integer index in string

 
ramesh kancherla
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use indexOf() methods ....

For more information you can google it or check java apis.
 
James Basller
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49796
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like a beginner's question. Sounds like a job for regular expressions.
 
ramesh kancherla
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49796
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by myself:
Sounds like a beginner's question. Sounds like a job for regular expressions.
Like that.
 
ramesh kancherla
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49796
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob: suggest you move this thread, please.

Ramesh: have you read the tutorial link I posted?
 
ramesh kancherla
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49796
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, of course you can create a regular expression for letters-numbers. Have you read the tutorial link?
 
ramesh kancherla
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 !




 
ram kumar
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
It is working fine. Thanks for your help.

Thanks & Regards
Ramesh k
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic