Hey I have to change in a lot of places camelCase to snail_case.
I have following example:
billingAddress
paymentDetails
I tried to use find and replace with regex in PhpStorm
In 'find' input field I put in:
([A-Z])
In 'replace' input field I put in:
_\L$1
Result I got:
billing_LAddress
payment_LDetails
What do I need to change in order to get following result:
billing_address
payment_details
First open Find and Replace functionality with
CTRL+Rand then check the boxesMatch CaseandRegex(and if necessaryIn Selection):1. To replace camelCase to snail_case as in in the question:
find:
([A-Z])replace:
_\l$1someThing -> some_thing2. To replace UPPERCASE words to lowercase words use
\Lfind:
(\w*)replace:
\L$1SOMETHING -> something3. To replace lowercase words to UPPERCASE words use
\Ufind:
(\w*)replace:
\U$1something -> SOMETHING4. To replace first character of words with lowercase use
\lfind:
(\w*)replace:
\l$1Something -> something5. To replace first character of words with UPPERCASE use
\ufind:
(\w*)replace:
\u$1something -> SomethingNote: Add some extra boundaries
You get best results by adding some additional boundaries that suit your specific case, for example single
'or double quotes"or line breaks\nRegex Documentation
Check for details on additional Regular Expression Syntax the documentation for PHPStorm or WebStorm.