An essential fragment changes the fragment, and also replace underscores with spaces in the mirror text

I have a few snippets for creating form elements in sublime text 2 for the blade.

To make the fragments more adequate, I would like to add functionality to convert the case in the mirrored text to a heading, as well as separate words with spaces instead of underscores.

This is a snippet from my snippet;)

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

Right now, when I print at position $ 1, the mirror text is converted to the title.

So, the result in a document with a blade can be, for example:

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

Now I also want to change the mirror text to replace underscores with spaces and convert THEN to a header. This is the part that I cannot understand.

So instead:

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

I want to end with this:

 {{ Form::label('password_confirmation', 'Password Confirmation') }} 
+6
source share
2 answers

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

Sublime Text uses Boost regular expressions that support conditionals .

+7
source
 <snippet> <content><![CDATA[ <div class="form-group"> {!! Form::label('${1:text}', '${1/(^|_)(.)/$1\u$2/g}:') !!} {!! Form::text('${1:text}', null, ['class' => 'form-control']) !!} </div> ]]></content> <!-- {!! Form::label('${1:text}', '${1/_/\ /-/g}:') !!} --> <tabTrigger>textfield</tabTrigger> 

The above is approaching, but not quite. He smooths the letter after underlining. The recorded line replaces the underscore with spaces ... I just can't figure out how to combine them: /

0
source

Source: https://habr.com/ru/post/975028/


All Articles