Here is your answer:

    String regex = "(?<=[\\d])(,)(?=[\\d])";
    Pattern p = Pattern.compile(regex);
    String str = "Your input";
    Matcher m = p.matcher(str);
    str = m.replaceAll("");
    System.out.println(str);

This only affects NUMBERS, not strings, as you asked.

Try adding that in your main method. Or try this one, it receives input:

       String regex = "(?<=[\\d])(,)(?=[\\d])";
        Pattern p = Pattern.compile(regex);
        System.out.println("Value?: ");
            Scanner scanIn = new Scanner(System.in);
            String str = scanIn.next();
        Matcher m = p.matcher(str);
        str = m.replaceAll("");
        System.out.println(str);
Answer from Whippet on Stack Overflow
🌐
Blogger
javahungry.blogspot.com › 2023 › 07 › remove-comma-from-number.html
Remove Comma from Number in Java [2 ways] | Java Hungry
We can easily remove the comma from a number using replace() method in Java as shown below in the example: public class RemoveCommaFromNumber { public static void main(String args[]) { String str1 = "123,456,789,0987,65"; str1 = str1.replace(",",""); System.out.println("Remove comma from number ...
Discussions

Java Regex Remove comma's between numbers from String - Stack Overflow
I am trying to parse a string, to remove commas between numbers. Request you to read the complete question and then please answer. Let us consider the following string. AS IS :) John loves cakes... More on stackoverflow.com
🌐 stackoverflow.com
java - Removing Dollar and comma from string - Stack Overflow
How can we remove dollar sign ($) and all comma(,) from same string? Would it be better to avoid regex? String liveprice = "$123,456.78"; More on stackoverflow.com
🌐 stackoverflow.com
java - how to remove a comma in a string - Stack Overflow
In your last question you wanted to add commas. Now you want to delete them. Maybe you should describe what you are actually trying to achieve... ... yes my customer wants to see number in comma separation but I have to do arithmetic operations on it, so I have to drop commas More on stackoverflow.com
🌐 stackoverflow.com
exception - How to parse number string containing commas into an integer in java? - Stack Overflow
0 How to convert string to integer when we have comma (,) in between word when used in java code ... 0 How to properly import a float/double number being a String in a CSV file to a program as float/double? 0 Selenium WD | Exception error appears after using parsing of String into double ... Why did God establish the New Covenant in a way that did not remove the Jewish objection from ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Sourcecodeera
sourcecodeera.com › blogs › Samath › Java-program-that-remove-comma-from-a-number.aspx
Java program that remove comma from a number
February 10, 2021 - import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); String number; String prefix; String postfix; System.out.print("Number (between 1,000 - 999,999, including comma): "); number = input.next(); input.close(); prefix = number.substring(0, number.length() - 4); postfix = number.substring(number.length() - 3); System.out.println(prefix + postfix); } }
🌐
Java2Blog
java2blog.com › home › core java › remove comma from string in java
Remove Comma from String in Java - Java2Blog
February 2, 2022 - You can use String’s replace() method to remove commas from String in java.
🌐
Quora
quora.com › How-can-commas-be-removed-from-an-integer-value-in-Java
How can commas be removed from an integer value in Java? - Quora
Answer: An int value contains a given number of bits - it does not have array of characters for a comma to be represented in, and so commas can’t exist to be removed in an int or Integer in java. If you want to parse a String to remove commas before trying to turn it into an int value, try [cod...
🌐
Brainmass
brainmass.com › computer-science › java › java-program-remove-comma-number-532817
Java: Program to remove comma from the number
Java: Program to remove comma from the number
The solution follows the hint provided in the posting. It accepts one number from the user and prints it after removing comma, if any, from it, and then exits.
Price   $2.49
Find elsewhere
🌐
Java-forums
java-forums.org › advanced-java › 12784-getting-rid-commas-large-numbers.html
Getting rid of commas in large numbers?
October 26, 2008 - so I need a general way to remove the commas in numbers. So let's first see your code that demonstrates your attempt to solve this, and then we'll then know where to go with this. ... So let's first see your code that demonstrates your attempt to solve this, and then we'll then know where to go with this. I'd like to simply use a regular expression in String.replaceAll.
🌐
Programming.Guide
programming.guide › java › remove-trailing-comma-from-comma-separated-string.html
Java: Removing trailing comma from comma separated string | Programming.Guide
String str = "lorem, ipsum, dolor, "; str = str.replaceAll(", $", ""); System.out.println(str); // "lorem, ipsum, dolor" , $ is a regular expression that means "comma, followed by a space, followed by end of string".
🌐
Coderanch
coderanch.com › t › 493434 › java › remove-comma-separator-string-values
remove comma separator from a string of values (Java in General forum at Coderanch)
April 28, 2010 - Are you able to put those Strings into a List<String> and iterate the list? You can have a loop with this sort of pseudo-code ... I solve this issue. Actually I change following and solve the issue. Thank you anyways for your idea. Change from: Change to: ... Still looks a complicated way to do it compared withYou would have to check whether the comma is an ordinary character or a meta-character in regular expressions first.
🌐
Reddit
reddit.com › r/javahelp › need help removing commas and a specific string from a string arraylist
r/javahelp on Reddit: Need help removing commas and a specific string from a string arraylist
February 16, 2015 -

import java.io.File; import java.util.ArrayList; import java.util.Scanner;

public class EmailReader {

    public static void main(String[] args) throws Exception {

            Scanner inputFile = new Scanner(new File("NameList.csv"));

            inputFile.nextLine();

            ArrayList<String> studentNames = new ArrayList();
            ArrayList<String> emails = new ArrayList();
            String ender = "@virginia.edu";

            while (inputFile.hasNext()) {

                    String name = inputFile.nextLine().concat("@virginia.edu");

                    studentNames.add(name);
            }
            for (int i = 0; i < studentNames.size(); i += 2) {

                    emails.add(studentNames.get(i));
                    ;

            }
            System.out.println(emails);

    }

}

🌐
Quora
quora.com › What-is-the-simplest-way-to-remove-the-last-comma-of-a-String-in-Java
What is the simplest way to remove the last comma of a String in Java? - Quora
Answer (1 of 7): The simplest way to remove the last comma is to not add it in the first place. You can use a loop [code]String sep = ""; StringBuilder sb = new StringBuilder() ; for (Object x: list) { sb.append(sep).append(x); sep = ","; } [/code]Or you can use [code]String s = list....
🌐
YouTube
youtube.com › dritalconnect
How to remove comma from number from string in JavaScript - YouTube
How to remove comma from number from string in JavaScript
Published   May 30, 2022
Views   910