DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2006
    Posts
    1

    getting content of string between two quotes

    Hi All...
    I am trying to get the content that is in between two href tags of a string. And after i get that content, i will need to process it further on. But how do i get only the content as shown below..

    <a href="/detail.html?detailID=56141">

    i only want "/detail.html?detailID=56141". Please help !!!...

    thanks,

  2. #2
    Join Date
    Jul 2005
    Posts
    78
    have a look at the indexOf() and substring() methods in the String class.

    That will allow you to get the index of a particular char or string, and then you can put those numbers into the substring method to give you your string sans the HTML bit.

  3. #3
    Join Date
    Feb 2006
    Location
    Cologne - Germany
    Posts
    271
    another approach: pattern and matcher classes for regex. but more difficult for people who are not fammiliar to regular expressions.

  4. #4
    Join Date
    Jan 2006
    Posts
    5
    public String token(String tokens){
    int a = 0;
    char s = tokens.charAt(a);
    String token = "";

    while(s != '>' ) {
    if(s == '<')
    token += "";
    else{
    token += s ;

    }
    a++;
    s = tokens.charAt(a);
    }

  5. #5
    Join Date
    Jan 2006
    Posts
    5
    Soryy for the mistake

    Code:
    public String token(String tokens){

  6. #6
    Join Date
    Jan 2006
    Posts
    5
    Again
    Soryy for the mistake

    Code:
    public String token(String tokens){
    int a = 0;
    char s = tokens.charAt(a);
    String token = "";
    
    while(s != '>' ) {
      if(s == '<')
        token += "";
      else{
         token += s ;
         
       }
       a++;
       s = tokens.charAt(a);
    }
    return tokens;

  7. #7
    Join Date
    Jan 2006
    Posts
    5
    Ah I am too tired,
    return tokens replace with;

    return token;

    Sorry, sorry, sorry very much
    As I said I am too tired today
    Again Sorry

  8. #8
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560

    A third approach

    Quote Originally Posted by graviton
    another approach: pattern and matcher classes for regex. but more difficult for people who are not fammiliar to regular expressions.
    For HTML parsing there is a set of classes ready made. I have attatched a simple app here that uses some of these features to extract the links, image-urls and the readable text from an HTML document.
    Attached Files
    eschew obfuscation

Similar Threads

  1. Input string was not in a correct format
    By mdengler in forum ASP.NET
    Replies: 0
    Last Post: 11-26-2002, 02:32 PM
  2. Replies: 1
    Last Post: 06-05-2001, 06:12 AM
  3. How do I detect an FTP timeout?
    By Julian Milano in forum VB Classic
    Replies: 2
    Last Post: 08-11-2000, 12:11 PM
  4. Please help me -- urgent -- deadlock error
    By chandra in forum VB Classic
    Replies: 0
    Last Post: 06-22-2000, 07:36 AM
  5. Database problems
    By Robert Rieth in forum VB Classic
    Replies: 1
    Last Post: 04-11-2000, 03:21 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links