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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:53:16+00:00 2026-06-08T05:53:16+00:00

How to Remove the Emoticons from the String My simple code is.. public static

  • 0

How to Remove the Emoticons from the String My simple code is..

public static void main(String[] args) throws SQLException {
    String str="My nam is  ur -D ";
    getRefineCode(str);
}

private static void getRefineCode(String str) throws {
    List smstypeWord=getshortWord();
    for(int i=0;i<smstypeWord.size();i++) {
        String string=smstypeWord.get(i).toString();
        String stringcon[]=string.split("_");
        String emessage=stringcon[0];
        String emoticon=stringcon[1].trim();
        if(str.contains(emoticon)) {
            str=str.replace(emoticon, emessage);
            System.out.println("=================>"+str);
        }   
    }
    System.out.println("=======++==========>"+str);
}

private static List getshortWord() throws SQLException {
    String query1 = "SELECT * FROM englishSmsText";
    PreparedStatement ps = conn.prepareStatement(query1);
    ResultSet rs = ps.executeQuery();
    String f_message="";
    String s_message="";
    while(rs.next()) {
        s_message=rs.getString("message");
        f_message=rs.getString("short_text");
        shortMessage.add(s_message+"_"+f_message);
        //fullMessage.add(f_message);
    }
    return shortMessage;
}

My database is based on http://smsdictionary.co.uk/abbreviations site

I able to understand how to remove the multiple abb. or short message

output is like My nam is You are SquintLaughtGrinisappGaspoooh!!shockedintedr, Big SmilGrinisappGaspoooh!!shockedinted, Grin

  • 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-08T05:53:20+00:00Added an answer on June 8, 2026 at 5:53 am

    First of all, replace should be replaceAll, otherwise you will only catch the first occurrence of an emoticon or abbreviation.

    Second, you can reduce the number of false positives by matching only whole words. replaceAll accepts regular expressions, so you can use replaceAll("\\b" + emoticon + "\\b", emessage) to only replace abbreviations which are surrounded by word boundaries (whitespace, punctuation etc.).

    However, with the dictionary you are using you will still replace KISS with Keep It Simple, Stupid. You will replace 86 with "out Of" Or "over" Or "to Get Rid Of"… Maybe you should be looking for a different approach.

    Edit: I forgot you were looking for special characters. You should try something like this regex, which will suppress special characters in the search string (and will be more generous than the previously too-strict \b pattern):

    replaceAll("((?<=\\W)|^)\\Q" + emoticon + "\\E((?=\\W)|$)", emessage);
    

    It should cover most cases, I doubt there is any way to perfectly identify what is intended as an acronym and what is not.

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

Sidebar

Related Questions

I'm trying to remove certain emoticons from a string, but I can't figure out
I'm trying to remove everything from a string that is NOT an html tag
I would like to remove the unwanted text from each string in a file.
To remove the language toggle from the page view(Comfirmation Page) I found this code
I'm looking to remove the all parentheses from a given string. After some research,
Here is the problem: Remove specified characters from a given string. Input: The string
I want to remove the domain extension .com from a string using preg_replace() ,
To remove white space from text i have written the below code.my requirement was
I remove item from ArrayList in foreach loop and get follwing exception. Collection was
in wrong i remove the path from my computer, now the path is empty

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.