gpt4 book ai didi

java:单词提取大写字母

转载 作者:行者123 更新时间:2023-12-02 06:18:39 25 4
gpt4 key购买 nike

如何使用java从单词中提取大写字母?

example:
enter your words:Hello I Am Heyman
output:HIAH

谢谢

最佳答案

您可以尝试替换全部

String text2 = text.replaceAll("[^A-Z]", "");

作为@Vic 评论,包括所有英语/非英语大写字母。

String text2 = text.replaceAll("[^\p{Lu}]", "");

关于java:单词提取大写字母,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10162281/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com