驼峰命名法删除号码
我正在尝试使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那里正在进行一些主要处理 - 因为它必须删除数字。然后,生成的字符串必须确定保留的单词(必须在 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.