Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to retrive something from a line of string

 
pradipta kumar rout
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
pradipta kumar rout
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pradipta kumar rout wrote:
I just want to retrive the URL.


That's exactly what Guido's code does. Try it.
 
Guido Granobles
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well there was a piece of text that was left at the end like:


So try with this pattern:
 
pradipta kumar rout
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic