replaceAll函数中的问题.....不能替换字符串中的所有字符 [英] problem in replaceAll function ..... not replace all characters in string
本文介绍了replaceAll函数中的问题.....不能替换字符串中的所有字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从字符串中删除元音,但它会替换所有字符,除了一个.........
这里是我的代码
i want to remove vowels from a string but it replaces all characters except for one.........
here is my code
package string;
public class MainString {
public static void main(String[] args) {
// TODO Auto-generated method stub
String s = "This is a string";
//s.replaceAll("aeiou", "");
removevowels(s);
}
public static void removevowels(String s)
{
String s1 = s.replaceAll("[aeiou](?!\\b)", "");
//String s1 = s.replaceAll("aeiou", "");
System.out.println(s1);
}
}
推荐答案
1。 用于删除给定字符串中元音的Java示例程序 [ ^ ]
2. 编写一种方法来删除Java字符串中的元音 [ ^ ]
1. Java Example Program for Delete vowels in given string[^]
2. Writing a method to remove vowels in a Java String[^]
这篇关于replaceAll函数中的问题.....不能替换字符串中的所有字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文