Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: extract specific text from a string

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default extract specific text from a string

    hi
    how do I extract the "http://www.javaprogrammingforums.com/one.jpg" and "some text" ?

    String str = <p><img src="http://www.javaprogrammingforums.com/one.jpg" alt=""></p> <p>some text</p>


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: extract specific text from a string

    I'm not sure if you're asking about using Strings in Java (refer to the String API) or if you're focused on web page scraping. If the latter, I recommend you search "java web page scraper" and read those results for info. Come back when you need more help.

  3. #3
    Member andbin's Avatar
    Join Date
    Dec 2013
    Location
    Italy
    Posts
    443
    Thanks
    4
    Thanked 122 Times in 114 Posts

    Default Re: extract specific text from a string

    Quote Originally Posted by smemamian View Post
    hi
    how do I extract the "http://www.javaprogrammingforums.com/one.jpg" and "some text" ?

    String str = <p><img src="http://www.javaprogrammingforums.com/one.jpg" alt=""></p> <p>some text</p>
    At least in two major ways:
    a) With a good use of regular expressions, thus directly manipulating strings.
    b) With a specialized library like jsoup (or others).
    Andrea, www.andbin.netSCJP 5 (91%) – SCWCD 5 (94%)

    Useful links for Java beginnersMy new project Java Examples on Google Code

Similar Threads

  1. extract selected text out of a pdf file using java
    By ashish.sharma in forum What's Wrong With My Code?
    Replies: 5
    Last Post: December 2nd, 2013, 04:01 AM
  2. how can I store text information on a specific line
    By leonne in forum Java Theory & Questions
    Replies: 6
    Last Post: October 20th, 2013, 07:33 PM
  3. extract senteces from a text document
    By priyankasarraf in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 11th, 2013, 03:07 AM
  4. Replies: 7
    Last Post: May 28th, 2013, 09:03 AM
  5. How to extract text from web
    By HelloAll in forum Java Theory & Questions
    Replies: 4
    Last Post: January 10th, 2011, 05:50 AM