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 7434973
In Process

The Archive Base Latest Questions

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

i have a html file and i have to load html content into my

  • 0

i have a html file and i have to load html content into my activity and i have not even heard of regular expression. could you friends help me do this.

I have the below html file and i need to get the {{book name}} and the rest of the content with regular expressions how to that, please help me thanks in advance

  • 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-29T09:58:58+00:00Added an answer on May 29, 2026 at 9:58 am

    I would use something like that:

    import java.util.StringTokenizer;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    
    class SimpleRegexExample {
        //TODO: Load your html content from file
        protected String html = "<html>\n"
                + "<head>\n"
                + "  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n"
                + " <meta http-equiv=\"Content-Style-Type\" content=\"text/css\">\n"
                + "  <title></title>\n"
                + "   <meta name=\"Generator\" content=\"Cocoa HTML Writer\">\n"
                + "   <meta name=\"CocoaVersion\" content=\"1038.36\">\n"
                + "    <style type=\"text/css\">\n"
                + "        p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 26.0px Helvetica}\n"
                + "        p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 19.0px Helvetica}\n"
                + "        p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}\n"
                + "        p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 19.0px Helvetica; min-height: 23.0px}\n"
                + "        p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}\n"
                + "    </style>\n"
                + "</head>\n"
                + "\n"
                + "    <body>\n"
                + "      <p class=\"p1\"><b>{{BookName}}</b></p>\n"
                + "      <p class=\"p2\">by {{AuthorName}}</p>\n"
                + "      <p class=\"p3\"><br></p>\n"
                + "      <p class=\"p3\"><br></p>\n"
                + "      <p class=\"p4\"><span class=\"Apple-converted-space\"> </span></p>\n"
                + "      <p class=\"p5\">{{AuthorBio}}</p>\n"
                + "      <p class=\"p3\"><br></p>\n"
                + "      <p class=\"p3\"><br></p>\n"
                + "      <p class=\"p5\">{{Credits}}</p>\n"
                + "      <p class=\"p3\"><br></p>\n"
                + "      <p class=\"p3\"><br></p>\n"
                + "   </body>\n"
                + "</html>\n";
    
        public SimpleRegexExample() {
            // Split the html text into single lines
            StringTokenizer st = new StringTokenizer(html, "\n");
    
            // Initialize the regex
            String regex = "\\{\\{(.*?)\\}\\}";
            Pattern p = Pattern.compile(regex);
    
            // Parses each line
            while (st.hasMoreTokens()) {
                String token = st.nextToken();
                Matcher m = p.matcher(token);
    
                // Searches for matches
                while (m.find()) {
                    if (m.group(1) != null) {
                        // TODO: Set here your replacement
                        html = html.replace("{{" + m.group(1) + "}}", m.group(1));
                    }
                }
            }
    
            // Prints the result
            System.out.println(html);
        }
    
        public static void main(String[] args) {
            new SimpleRegexExample();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using file_get_contents('mysourcefile.html') to load the contents of mysourcefile.html into mysql db. I have
I have the following code in my file to load a div with HTML
I have javascript code embedded inside a html template file. When I load this
Good evening everyone, I am using a JavaScript to load/override content from an HTML-File
Using either .ajax or .load, I'm loading content from an .html page into or
Hi have a JQuery modal popup that I load HTML into. I have the
Im trying to load content into a DIV from an XML file when the
I have an html file in /mnt/sdcard/packagename/files/something.html path. Now I want to load this
I have html-file. I have to replace all text between this: [%anytext%]. As I
I have a HTML file that has code similar to the following. <table> <tr>

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.