Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular Expression to remove space ,comma ,space from a string in java? [closed]

Tags:

java

regex

i Have a string s "hello,sa n.txt"

but i want the string s ="hellosan.txt" no comma,no space, no semicolon,should be there How can i do this in java Using regular expression?

like image 825
Sandeep Sokhal Avatar asked Feb 12 '26 22:02

Sandeep Sokhal


1 Answers

String input = "hello,sa n.txt";
String clean = input.replaceAll("[, ;]", ""); // replace any of ", ;" with "nothing"
like image 125
Bohemian Avatar answered Feb 15 '26 19:02

Bohemian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!