aspose file tools*
The moose likes I/O and Streams and the fly likes how ro get a string from a string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "how ro get a string from a string" Watch "how ro get a string from a string" New topic
Author

how ro get a string from a string

adeeb alexander
Ranch Hand

Joined: May 29, 2008
Posts: 268
Hi
i want to extract a part of the string. The string is just like this java is a 'programming' language. Now my need is do extract the text between ' ' .How can i achieve this any help would be appreciated.

Thanks and Regards
alexander
Scott Bravo
Greenhorn

Joined: Jun 15, 2009
Posts: 18
what's the prob in it ,you can do like this ....if still you need some other way please specify in detail ...


adeeb alexander
Ranch Hand

Joined: May 29, 2008
Posts: 268
Hi.
My requirement is not that see example below you might understand.
String a=" 'porsches car' , 'ferrari,car', yamaha bike ,'sdsDs fare' , efre asfasf ";

How to split that string. I tried to split with split(",") but see at the word 'ferrari,car ' it is one word now how to do. Whwn i use split(",\\s?+") i get the out put some thing like this

'porsches car'
'ferrari
car'
yamaha bike
'sdsDs fare'
efre asfasf

But the word 'ferrari,car' is one word not different the user has given a comma but whenever the user gives like those type of words he will give in between ' '. So the user have given the word ferrari,car like this 'ferrari,car'. Now i am un able to split it.
Hope you got my problem.

Thanks and regards
alexander
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19693
    
  20

Scott Bravo wrote:what's the prob in it ,you can do like this ....if still you need some other way please specify in detail ...



Just a small note: when looking for single characters, the indexOf(char) and indexOf(char, int) methods are a little more efficient:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Scott Bravo
Greenhorn

Joined: Jun 15, 2009
Posts: 18
Adeeb I think Pattern and Matcher class can solve your probelm..try to write a regular expression according to your requirement then do the processing of the text..
-Bravo
adeeb alexander
Ranch Hand

Joined: May 29, 2008
Posts: 268
Hi Bravo
What you thought is wright. But i need an example to understand it. I need just the simple example.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10375
    
    8

Check this out


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Scott Bravo
Greenhorn

Joined: Jun 15, 2009
Posts: 18
Maneesh has provided a good example check his link
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how ro get a string from a string