Remove the specified character from the string

Source: Internet
Author: User

You can use another method to remove the specified characters in a string? Replace it with "". The Code is as follows: String s = "?????! Http://t.cn/zlkjUY5 ??????? "; Int idex = 0; s = s. replaceAll ("? "," "); System. out. println (s); Result :! The following is a slightly complex usage of the http://t.cn/zlkjUY5: public static String getString (String str) {// define a set to store the decomposed Character List <String> list = new ArrayList <String> (); String streee = ""; for (int I = 0; I <str. length (); I ++) {streee = str. substring (I, I + 1); list. add (streee) ;}// define a StringBuffer strb = new StringBuffer (); for (int j = 0; j <list. size (); j ++) {String a = list. get (j ). toString ();// If not? Add this character to the StringBuffer if (! A. equals ("? ") {Strb. append (a) ;}else {}} System. out. println (strb); return strb. toString ();}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.