Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
602 views
in Technique[技术] by (71.8m points)

Atom Editor: RegEx replace to uppercase/lowercase

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

Let’s say I have the string:

some:test:sequence

and want the result:

Some:Test:Sequence

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.

question from:https://stackoverflow.com/questions/28673382/atom-editor-regex-replace-to-uppercase-lowercase

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

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)

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.

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:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...