Use Sublime Text string containing the underlined batch replace string format to a hump nomenclature

This article belongs cxun all, if reproduced please indicate the source and link to this article, thank you!
Original Address: http: //www.cnblogs.com/cxun/p/7762984.html

 

For indexing: Convert strings like under_score to strings like camelCase

 

Sublime use, containing regular expressions tool replacement text processor, in the following manner, batches such as "abc_def_ghi" Notepad ++ alternative such as "abcDefGhi" format.

First of all, it must first replace the string contains more underlined, for example, you want to replace a large number of string inside, each containing a number of variables have an underscore and two, it would replace the first two, and then replace 1, and so forth. The following example contains two alternative underlined:

Regular expression search: (\ w *) _ (\ w *) _ (\ w *)

Replace: \ l \ 1 \ u \ 2 \ u \ 3

This means that the characters within the brackets as an element, is separated by underscores, the first letter of the first element of the lowercase, the first letter of the second and third elements of capital into between each element.

Then replace only contains one underlined:

Regular expression search: (\ w *) _ (\ w *)

Replace: \ l \ 1 \ u \ 2

By the same token, if you want to replace the text, there are "abc_def_ghi_jkl", then it is replaced with the first three underlined, and then replaced with two, and finally replaced with one, and so on. Thus, it can replace a large number of variables to be separated by an underscore format hump nomenclature friends ~

 

1. Alternatively three "_" 
(\ W *) _ (\ W *) _ (\ W *) _ (\ W * )
\ to \ 1 \ and \ 2 \ and \ 3 \ and \ 4

2. Replace the two "_" 
(\ W *) _ (\ W *) _ (\ W * )
\ to \ 1 \ and \ 2 \ and \ 3
3. Replace a "_" 
(\ W *) _ (\ W * )
\ to \ 1 \ and \ 2

 

references:

1. Regex - converting to CamelCase and cutting founded word

(https://stackoverflow.com/questions/25477034/regex-converting-to-camelcase-and-cutting-founded-word)

\l     # first character to lower case
\u     # first character to upper case
\L     # start of lower case conversion
\U     # start of upper case conversion
\E     # end lower/upper case conversion

2. Regular Expressions 30 minutes Start Tutorial

(http://www.jb51.net/tools/zhengze.html)

Guess you like

Origin www.cnblogs.com/nov5026/p/11896771.html