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

  • Home
  • SEARCH
  • 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 8587641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:37:03+00:00 2026-06-11T22:37:03+00:00

Ok So I have two strings. The First String is a word, the second

  • 0

Ok So I have two strings. The First String is a word, the second string is a sentance. Now the sentence contains the word, and also a definition for the word. See the example below.

Word String : AED
Sentence String : This will be much like the “Kindle” or automated external defibrillator (AED).

So I need to find the definition: automated external defibrillator of the word: AED.

What I need to do is parse and find the Definition. I am currently stuck and I need a little help on this. The logic below breaks the word into an array and the sentence into an array. Unfortunately this isn’t complete. And also when the logic is looking at the first letter of the word it won’t really work as A in AED is uppercase and a in automatic is lowercase.

private void getDefinitions(String word, String sentence) {
    if (sentence.contains(word)) {
        String[] wordStrAry = word.split("");
        String[] sentStr = sentence.split(" ");
        for (int sentInt = 0; sentInt < sentStr.length; sentInt++){
            for (int wordInt = 0; wordInt < wordStrAry.length; wordInt++) {
            wordStrAry[wordInt].trim();
                if (!wordStrAry[wordInt].equals("")) {
                    if (sentStr[sentInt].startsWith(wordStrAry[wordInt])){
                        System.out.println(sentStr[sentInt]);
                    }
                }
            }
        }
    }
}

One little bit of information I forgot is I need to pull the definition out of the sentence and display it in a text box.

  • 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-06-11T22:37:04+00:00Added an answer on June 11, 2026 at 10:37 pm
    public static String getDefinition(String acronym, String sentence) {
        if (!sentence.toLowerCase().contains(acronym.toLowerCase())) {
            return null;
        }
    
        StringBuilder patternBuilder = new StringBuilder();
        for (char letter : acronym.toCharArray()) {
            patternBuilder.append("[");
            patternBuilder.append(Character.toLowerCase(letter));
            patternBuilder.append(Character.toUpperCase(letter));
            patternBuilder.append("]");
            patternBuilder.append("\\w*\\s+");
        }
        patternBuilder.delete(patternBuilder.length() - 3, patternBuilder.length());
    
        Pattern pattern = Pattern.compile(patternBuilder.toString());
        Matcher matcher = pattern.matcher(sentence);
        if (!matcher.find()) {
            return null;
        }
    
        return matcher.group();
    }
    
    public static void main(String[] args) {
        String acronym = "AED";
        String sentence = "This will be much like the \"Kindle\" or Automated External Defibrillator (AED)";
        String definition = getDefinition(acronym, sentence);
        if (definition != null) {
            System.out.println(acronym + " = " + definition);
        } else {
            System.out.println("There is no definition for " + acronym);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have many urls(string): $one = 'http://www.site.com/first/1/two/2/three/3/number/342'; $two = '/first/1/two/2/number/32'; $three = 'site.com/first/1/three/3/number/7'; $four
I have two strings str1 and str2 . Check both of them and see
I have two strings String s1=426F62; String s2=457665; The strings are in hex representation.
I have two arrays, each containing strings. The first array is a list of
Let's say that I have a two word string and I want to capitalize
I have two strings in a java program, which I want to mix in
I have two strings, one a key and one a value, which I would
i have two strings in a php i want to make following checks in
If I have two strings that are identical in value, is it guaranteed that
Let's say I have two strings: one is XML data and the other 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.