驼峰命名法删除号码

发布于 2024-09-25 17:12:22 字数 286 浏览 3 评论 0原文


我正在尝试使用 CamelCase 来分隔单词,以便正确制作标题。
其中一些字符串还带有数字。例如:1962NBAFin4als 变为 NBA Finals。所以它只是忽略数字。
我尝试在互联网上进行一些研究,但没有发现任何有用的信息。

是CamelCase的问题吗?
我的java代码是:

String fName = Utils.unCamelCase(myString);

提前致谢

I am trying to use CamelCase to separate words in order to make title properly.
Some of these strings are also with number. For example: 1962NBAFin4als becomes NBA finals. So it is just ignoring numbers.
I tried to do some research in internet, but I haven't found anything helpful.

Is it a problem of CamelCase??
My java code is:

String fName = Utils.unCamelCase(myString);

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

唯憾梦倾城 2024-10-02 17:12:22

那里正在进行一些主要处理 - 因为它必须删除数字。然后,生成的字符串必须确定保留的单词(必须在 NBA 和 Finals 之间放置一个空格),最后它必须知道哪些单词保留全部大写,哪些单词保留驼峰式大小写。这并不是你真正能在方法中找到的东西——事实上,公司提供这样的服务来清理你的数据并利用它过上美好的生活。

抱歉,这是个坏消息,但这是一个很大的话题。您还必须考虑中间有大写字母的名称(例如MacDonalds)。您不要将其拆分,并且 D 也不应该是小写。

You've got some major processing going on there - in that it has to strip out numerics. Then the resulting string it has to determine the words that are left (it has to put a space between NBA and Finals) and then finally it has to know which words to leave all upper case and those to camel case. It's not something you're really going to find in a method - in fact companies provide services like this to clean your data and make a very good living out of it.

Sorry it's bad news, but it's a huge subject. You also have to factor in names that have upper case in the middle (like MacDonalds). You don't split it and the D shouldn't be lower case either.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文