我怎么能砍(1)首字母大写的话吗? [英] How can I cut(1) camelcase words?

查看:346
本文介绍了我怎么能砍(1)首字母大写的话吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有击一个简单的方法来一个字驼峰拆分成其组成词?

Is there an easy way in Bash to split a camelcased word into its constituent words?

例如,我想aCertainCamelCasedWord分成某骆驼套管字,并能够选择那些我感兴趣的领域。这是平凡与切割完成(​​1)当词分隔符是下划线,但我怎么能做到这一点时,字是驼峰格式?

For example, I want to split aCertainCamelCasedWord into 'a Certain Camel Cased Word' and be able to select those fields that interest me. This is trivially done with cut(1) when the word separator is the underscore, but how can I do this when the word is camelcased?

推荐答案

SED的/ \\([AZ] \\)/ \\ 1 / G'

捕获每个大写字母和替代与捕获整个流的前导空格。

Captures each capital letter and substitutes a leading space with the capture for the whole stream.

$ echo "aCertainCamelCasedWord" | sed 's/\([A-Z]\)/ \1/g'
a Certain Camel Cased Word

这篇关于我怎么能砍(1)首字母大写的话吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆