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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:28:15+00:00 2026-05-15T02:28:15+00:00

i want to know how to write pattern.. for example : the word is

  • 0

i want to know how to write pattern..

for example :

the word is

   "AboutGoogle AdWords Drive traffic and customers to your site. Pay through Cheque,      Net Banking or Credit Card. Google Toolbar Add a search box to your browser. Google SMS To find out local information simply SMS to 54664. Gmail Free email with 7.2GB storage and less spam. Try Gmail today. Our ProductsHelp Help with Google Search, Services and ProductsGoogle Web Search Features Translation, I'm Feeling Lucky, CachedGoogle Services & Tools Toolbar, Google Web APIs, ButtonsGoogle Labs Ideas, Demos, ExperimentsFor Site OwnersAdvertising AdWords, AdSenseBusiness Solutions Google Search Appliance, Google Mini, WebSearchWebmaster Central One-stop shop for comprehensive info about how Google crawls and indexes websitesSubmit your content to Google Add your site, Google SitemapsOur CompanyPress Center News, Images, ZeitgeistJobs at Google Openings, Perks, CultureCorporate Info Company overview, Philosophy, Diversity, AddressesInvestor Relations Financial info, Corporate governanceMore GoogleContact Us FAQs, Feedback, NewsletterGoogle Logos Official Logos, Holiday Logos, Fan LogosGoogle Blog Insights to Google products and cultureGoogle Store Pens, Shirts, Lava lamps©2010 Google - Privacy Policy - Terms of Service"

I have to search some word…

for example “google insights”

so how to write the code in java…

i just write small code…

check my code and answer my question…

that code only use for find the search word, where is that.

but i need to display some words front of search word and display some words rear of search workd…

similar to google search…

my code is

Pattern p = Pattern.compile("(?i)(.*?)"+search+"");
Matcher m = p.matcher(full);
String title="";
while (m.find() == true) 
{
  title=m.group(1);
  System.out.println(title);
} 

the full is orignal content, search s search word…

thanks and 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-15T02:28:16+00:00Added an answer on May 15, 2026 at 2:28 am

    The best solution would have to use really sophisticated string search and indexing algorithms. If you don’t care about performance, something like this is quite easy to implement:

    import java.util.*;
    public class SearchAndContext {
        public static void main(String[] args) {
            String text = "The path of the righteous man is beset on all sides by "
            + "the iniquities of the selfish and the tyranny of evil men. Blessed "
            + "is he, who in the name of charity and good will, shepherds the "
            + "weak through the valley of darkness, for he is truly his brother's "
            + "keeper and the finder of lost children. And I will strike down "
            + "upon thee with great vengeance and furious anger those who would "
            + "attempt to poison and destroy my brothers. And you will know my "
            + "name is the Lord when I lay my vengeance upon thee.";
    
            List<String> words = Arrays.asList(text.split(" "));
            final int W = 3;
            final int N = words.size();
            String[] queries = { "vengeance", "and", "monkeys" };
            for (String query : queries) {
                List<String> search = words;
                System.out.println("Searching for " + query);
                for (int idx = -1, pos; (pos = search.indexOf(query)) != -1; ) {
                    idx += (pos+1);
                    int left = Math.max(0, idx - W);
                    int right = Math.min(N, idx + W + 1);
                    System.out.println(words.subList(left, right));
                    search = search.subList(pos+1, search.size());
                }
            }
        }
    }
    

    This prints:

    Searching for vengeance
    [thee, with, great, vengeance, and, furious, anger]
    [I, lay, my, vengeance, upon, thee.]
    Searching for and
    [of, the, selfish, and, the, tyranny, of]
    [name, of, charity, and, good, will,, shepherds]
    [his, brother's, keeper, and, the, finder, of]
    [with, great, vengeance, and, furious, anger, those]
    [attempt, to, poison, and, destroy, my, brothers.]
    Searching for monkeys
    

    As you can see, this finds occurrences of the search query, and also provides the context of up to W=3 words around the “hit”.

    API references

    • java.util.List
      • indexOf(Object)
      • subList(int fromIndex, int toIndex)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 434k
  • Answers 434k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Why not just put an <h2> or <h3> tag above… May 15, 2026 at 3:20 pm
  • Editorial Team
    Editorial Team added an answer Yes, Views Bulk Operations will get this done. It will… May 15, 2026 at 3:20 pm
  • Editorial Team
    Editorial Team added an answer I've given up after a little try to follow what… May 15, 2026 at 3:20 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.