所有元音的打印字符串替换为下划线 - java

时间:2016-10-26 17:15:58

标签: java string

java新手...这里是代码。可以工作,但可以打印到很多实例。

[12:22:19] Starting 'jekyll-build'...
Configuration file: C:/repo/drago-cms/_config.yml
        Source: C:/repo/drago-cms
   Destination: C:/repo/drago-cms/_site
Incremental build: enabled
  Generating...
Error reading file C:/repo/drago-cms/_layouts/compress.html: No such file or directory @ rb_sysopen - C:/repo/Drago-CMS/repo/drago-cms/_layouts/compress.html
Error reading file C:/repo/drago-cms/_layouts/default.html: No such file or directory @ rb_sysopen - C:/repo/Drago-CMS/repo/drago-cms/_layouts/default.html
Error reading file C:/repo/drago-cms/_layouts/index.html: No such file or directory @ rb_sysopen - C:/repo/Drago-CMS/repo/drago-cms/_layouts/index.html
Error reading file C:/repo/drago-cms/_layouts/page.html: No such file or directory @ rb_sysopen - C:/repo/Drago-CMS/repo/drago-cms/_layouts/page.html
Error reading file C:/repo/drago-cms/_layouts/post.html: No such file or directory @ rb_sysopen - C:/repo/Drago-CMS/repo/drago-cms/_layouts/post.html

示例输出:__SY__SY__SY__SY(输入“easy”)。 感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

删除你想要只更换一次的for循环...打印String upperCaseInput = input.toUpperCase();
System.out.print(upperCaseInput.replaceAll("[AEIOU]", "_") );
次...... 就这样做

2