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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:23:27+00:00 2026-06-18T01:23:27+00:00

In Android ,i have a TextView ,inside the textview ,it contains some text example(22

  • 0

In Android ,i have a TextView ,inside the textview ,it contains some text example(22 likes,some times 1 like or empty text).Here i want to get only numbers not characters.so using how to use the String.replaceAll() to get the numbers exactly without empty text.
Here is a sample code …

textview.setText("2 Likes");
String com=textview.replaceAll("","");
  • 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-18T01:23:28+00:00Added an answer on June 18, 2026 at 1:23 am

    use String.split to split string in Array as :

    textview.setText("2 Likes");
    String strtxt=textview.getText();
    
    String[] arrliks = strtxt.split(" ");  
    String num_of_likes=arrliks[0]; //<<< get 2 here
    

    and you can also use regex expressions to split string

    EDIT :

    you call also use String.replaceAll as :

       String com=textview.getText();
       String liks = "likes";
       String str_new   ="";
      if (com.toLowerCase().indexOf(liks) != -1) {
         str_new=com.replaceAll(" Likes","");
       }else{
         str_new=com.replaceAll(" like","");
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have constant text inside editText like: http://<here_user_can_write> User should not be
I have the following TextView in my XML layout file:- <TextView android:layout_width=fill_parent android:layout_height=wrap_content android:text=@string/autolink_test
I have some problem with displaying emoji icon in Android TextView First, I found
I have different table rows, each of it contains some information text which should
I have a some ui widgets including textview inside RelativeLayout which is clickable. My
Beginner Android and Java developer here. I have this snippet of code inside a
I want to center a text inside a TextView relative to the parent layout
I have Layout XML Like this. This is inside LinearLayout. <TableLayout android:layout_width=fill_parent android:layout_height=fill_parent> <TableRow
I have a listview which contains 2 Textview. one textview is shown inside a
I have TextView inside FrameLayout and I want to draw fading edge of FrameLayout

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.