How Do I Remove Special Characters from a Text File in Linux?
Contents How Do I Remove All Special Characters from a String? Example of Removing Special Characters Using replaceAll() Method Public Class...
Contents
How do I remove all special characters from a string?
Example of removing special characters using replaceAll() method
- public class RemoveSpecialCharacterExample1.
- {
- public static void main(String args[])
- {
- String str= “This#string%contains^special*characters&.”;
- str = str.replaceAll(“[^a-zA-Z0-9]”, ” “);
- System.out.println(str);
- }
Must Read
How do I remove a character from a string in Linux?
Remove Character from String Using tr
The tr command (short for translate) is used to translate, squeeze, and delete characters from a string. You can also use tr to remove characters from a string.