崇高的代码段更改大小写,以及用镜像文本中的空格替换下划线 [英] Sublime snippet change case as well as replace underscores with spaces in mirrored text

查看:85
本文介绍了崇高的代码段更改大小写,以及用镜像文本中的空格替换下划线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个代码片段,用于在刀片的Sublime Text 2中创建表单元素.

I have several snippets for creating form elements in sublime text 2 for blade.

为了使代码片段更加充分,我想添加功能,以将镜像文本中的大小写转换为标题大小写",并用空格而不是下划线分隔单词.

In order to make the snippets more sufficient, I would like to add the functionality to convert the case in the mirrored text to Title Case as well as separate the words with spaces instead of underscores.

这是我的代码段中的一个代码段;)

This is a snippet from my snippet ;)

{{ Form::label('$1', '${1/\b(\w*)\b/\u\1/g}') }}

现在,当我在$ 1位置键入内容时,镜像文本将转换为标题大小写.

Right now when I type at position $1, the mirror text gets converted to title case.

因此,刀片文档中的结果可能是例如:

So, the result in the blade document could be for example:

{{ Form::label('password', 'Password') }}

现在,我还想更改镜像文本以将下划线替换为空格,然后将其转换为标题大小写. 这是我不知道的部分.

Now, I also want to change the mirror text to replace underscores with spaces and THEN convert to title case. This is the part I can't figure out.

所以,代替这个:

{{ Form::label('password_confirmation', 'Password_confirmation') }}

我要结束这个:

{{ Form::label('password_confirmation', 'Password Confirmation') }}

推荐答案

{{ Form::label('$1', '${1/^(\w)|(_(\w))/(?1:\u\1:)(?2: \u\3:)/g}') }}

Sublime Text使用支持

Sublime Text uses Boost regular expressions which support conditionals.

这篇关于崇高的代码段更改大小写,以及用镜像文本中的空格替换下划线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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