Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4018408
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:58:45+00:00 2026-05-20T09:58:45+00:00

My android application downloads articles formatted with HTML tags and displays them in the

  • 0

My android application downloads articles formatted with HTML tags and displays them in the WebView. The problem I have got is that some articles have auto generated graphs which are quite big and they don’t fit the webview. (Please note that I don’t want to use horizontal scrolling).
My idea is to save every occurrence of the ‘div’ tag that holds such a graph and then replace it with "<a href='unique_id_of_div_tag'>Show graph</a>" link.
Having something like this will display link instead of the graph. When user click on it would open new activity with graph.(I would handle user clicks with WebViewClient and shouldOverrideUrlLoading method)

The ‘div’ tag which contains the grap info has similar structure to the following:

<div class="graph">
   <div>Header</div>
   <div>Graph body</div>
   <div>Graph footer</div>
</div>

(and I don’t have a control over it)

To sum up, I want to be able to save content of the<div class="graph">...</div> and replace it with <a href="">...</a>. How can I achieve that?

Thanks,
marqs

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:58:46+00:00Added an answer on May 20, 2026 at 9:58 am

    This can be done by using the following:

    Pattern tags = Pattern.compile ("</?[^>]+>");
    Matcher match = tags.matcher (yourContent); // here you specify the string you want to modify (HTML)
    String result = match.replaceAll("");
    

    This way you remove any tags, but keep the content in your HTML string.

    Read more about Pattern and Matcher here.

    EDIT:

    To remove only links (anchors) from the string, write the following instead of the first line:

    Pattern tags = Pattern.compile ("</?[a]{1}[^>]+>");
    

    You can remove an arbitrary string by just replacing the regular expression with another one.

    EDIT2:

    I completely misunderstood your question. Two times 🙂

    You can remove all <div class="graph"> tags, by doing something like this:

        Pattern tags = Pattern.compile ("<div class=\"graph\">[^(</div>)]+</div>");
    

    Afterwards, replace all those [[DIV]] placeholders with whatever you want. However, this approach will not work if you have a div with a graph AND some content inside it, though. So in that case, I think it will be best to split all your content on the <div class=graph> and then inspect every DIV inside every element to check if there is a graph inside it.

    I don’t know if this can be done with regular expressions alone, so a more tedious and bug-prone approach will have to be undertaken. But you do want something really specific, so that’s something you should expect sometimes 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to develop an application for the android platform that can download some
I am creating an Android application which will have some embedded music inside of
I've got a problem to publish my Android Application. here's what i've done, so
I have a C++ Android application that I'm trying to debug with ndk-gdb. The
I have an Android application which handles a particular type of file. It registers
I am having problem with download my android application from my own web server.
I have written an Android Application and the generated .APK file I uploaded in
I've read the guide about application data backup in Android here http://developer.android.com/guide/topics/data/backup.html , but
I am a beginner to android. I am building an application to work with
In my android application i am playing videos using video view.While the video is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.