How to replace non alphabets in String using Regular Expression

/** *  */package com.onlinecodegeek.java.util;/** * @author tponnam * */public class ReplaceNonAlphabetsInString { /**  * @param args  */ public static void main(String[] args) {  // TODO Auto-generated method stub    String str = "Hello & World @# .. World of &2 Java";  str = str.replaceAll("[^a-zA-Z]+", "");  System.out.println(str.trim()); }}

SHARE

    Blogger Comment
    Facebook Comment

0 comments :

Post a Comment