File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes how to retrive something from a line of string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to retrive something from a line of string " Watch "how to retrive something from a line of string " New topic
Author

how to retrive something from a line of string

pradipta kumar rout
Ranch Hand

Joined: Sep 13, 2010
Posts: 43
Sir,

I want to retrive " http://something.com " from <a href=" http://something.com">.I have saved the html file in a .txt file but how
to retrive that perticular "http://something.com" from this line.
kindly tell me .kindly help me sir...................


Example:
if writen <a href="http://www.yahoo.com">yahoo</a> then
I want only http://www.yahoo.com .

if writen <a href="http://www.gmail.com">yahoo</a> then
I want only http://www.gmail.com.



Thank you
Pradipta
Guido Granobles
Greenhorn

Joined: Sep 11, 2010
Posts: 22
You can use regular expressions in order to find all matches for any url within a text line. It would be like this:


So just write a method that returns the matches found.


http://guido-granobles.blogspot.com
pradipta kumar rout
Ranch Hand

Joined: Sep 13, 2010
Posts: 43
To :Guido Granobles



Sir,
Thank you for your response,
Sir, I just want that URL I do not want to match them with any other .

Example:
if writen <a href="http://www.yahoo.com">yahoo</a> then i want
only http://www.yahoo.com should retrived and strored in any variable.

if writen <a href="http://www.gmail.com">gmail</a> then i want
only http://www.gmail.com should retrived and strored in any variable.


I just want to retrive the URL.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

pradipta kumar rout wrote:
I just want to retrive the URL.


That's exactly what Guido's code does. Try it.


[Jess in Action][AskingGoodQuestions]
Guido Granobles
Greenhorn

Joined: Sep 11, 2010
Posts: 22
Well there was a piece of text that was left at the end like:


So try with this pattern:
pradipta kumar rout
Ranch Hand

Joined: Sep 13, 2010
Posts: 43
Sir,

Thank you for your reply,

now i want to retrive
Example 1. pradipta from : <title>Pradipta</title>
2. xyz form : <title>xyz</title>

like this .. i want to retrive the title name..

kindly help me how to retrive this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to retrive something from a line of string