Hackerss.com is a community of amazing hackers

Hackerss is a community for developers, data scientitst, ethical hackers, hardware enthusiasts or any person that want to learn / share their knowledge of any aspect of digital technology.

Create account Log in

Posted on

Java From a string remove characters that are no letters nor numbers nor dots nor commas

public class RemoveSpecialCharacters {
    public static void main(String[] args) {
        String str = "Hello, World! 123";
        System.out.println(str.replaceAll("[^a-zA-Z0-9.,]", ""));
Enter fullscreen mode Exit fullscreen mode

Top comments (0)