Atom 编辑器:RegEx 替换为大写/小写 [英] Atom Editor: RegEx replace to uppercase/lowercase

查看:42
本文介绍了Atom 编辑器:RegEx 替换为大写/小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试用 Atom 编辑器中的大写/小写等效项替换字符串中的某些字符.

I'm trying to replace some characters in a string with their uppercase/lowercase equivalents in Atom Editor.

假设我有字符串:

some:test:sequence

并想要结果:

Some:Test:Sequence

我知道诸如 u$1l$1 之类的东西,但它们在 Atom 中不起作用,因为 Atom 使用的是 JS 风格的 RegEx.然而,我发现的 JS-RegEx 解决方案总是涉及调用一个函数(参见此处的示例),这在原子,阿费克.

I’m aware of things like u$1 and l$1, but they do not work in Atom, as Atom is using JS-style RegEx. The JS-RegEx solutions I found, however, always involve calling a function (see example here), which is not possible in Atom, afaik.

有谁知道是否有办法实现这一目标?我也不介意为更强大的正则表达式搜索/替换安装一个包,但还没有找到,我想避免为此而自己编写一个包.

Does anyone know if there is a way to achieve this? I also don’t mind installing a package for a more powerful regex search/replace, but haven’t found one and I’d like to avoid writing one on my own just for this.

请注意:我不是在寻找查找/选择字符的解决方案.选择工作得很好,但比示例中的要复杂一些.

Please note: I’m not looking for a solution to find/select the characters. The selection works just fine and is a bit more complex as in the example.

推荐答案

请注意,虽然您说问题与选择无关,但我使用的是更简单的示例.

Note that whilst you said the question is not about the selection, I'm using a more simplified example.

如果您有一个由以下内容组成的字符串: 这是一个大小写混合的字符串!我希望每个字母都以大写开头.

If you have a string consisting of: This is a Mixed case String! I want every Letter to Start with A Capital.

您可以使用 w 的正则表达式选择器来查找字符串中每个单词的第一个字符.(通过 Cmd + F 完成并单击右侧菜单上的 .* 进行正则表达式搜索)

You can use the Regex selector of w to find the first characters of every word in the string. (Done by Cmd + F and clicking .* on the right hand menu for Regex search)

现在按 Alt + Enter 选择所有找到的结果,这应该突出显示 Regex 查询的所有结果.在此之后,要使每个第一个字母大写,您可以按 Cmd + K ->Cmd + U,你可以从这里随意修改它们.

Now press Alt + Enter to select all of the found results, this should highlight all results of the Regex query. Following this, to make every first letter uppercase you can press Cmd + K -> Cmd + U, you can modify them however you want from here.

轰!该字符串现在应如下所示: This Is A Mixed Case String!我希望每个字母都以大写开头.

Boom! The string should now look like: This Is A Mixed Case String! I Want Every Letter To Start With A Capital.

我一直在寻找这个问题的答案,以下是我的答案来源:

I've been looking for an answer for this question for a while, here are my sources for the answer:

johno 关于如何从正则表达式搜索中选择所有结果的答案(答案中包含相关拉取请求)

这篇关于Atom 编辑器:RegEx 替换为大写/小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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