Highlighting CamelCase in WebStorm - webstorm

Is there any possibility to play with editor setting in order to achieve that ?
I would like to see if there is an option to highlight the Camel Cased letters, with different color or different brightness.

Related

Is it possible to find a group based on its content but with alternatives?

I'm experimenting a bit with the regex and in particular with groups. Let's suppose I have the following text
I like blue. Do you like red?
I like blue. Do you like blue?
I like red. Do you like blue?
I like red. Do you like red?
I know that the referenced group g{1} matches the exact text but I was wondering if there is a way, using groups, to match all my lines even of the 2 colours are different.
Atm my regex is I like (blue|red). Do you like \g{1}\?
Thanks
It would be best to specify what environment or programming language you are using. PCRE, Perl, and .NET support recursive subpatterns, so for example, this will work in PHP but not JavaScript.
I like (blue|red)\. Do you like (?1)\?

How can I replace all camel case strings with kebab case strings in vscode with find and replace

I have a large collection of html files for a vue project that currently have inconsistent prop usage
some props are v-bind:prop-name="" some are v-bind:propName="" and some use the short hand :prop-name="" or :propName="".
and I would like to replace all props with the :prop-name="" syntax as per the vue docs.
I know that you can use regex in vscode (or a similar editor) to select only props with a camelCase format but im having a few issues.
for the find regex I cant figure out how to:
select v-bind: or : as a prefix AND exclude it from a selection group
split the camelCased string into selection groups
dealing with propNameWithMoreThanTwoWords
for the replace syntax im pretty sure I have the right syntax
:\L$1-$2=" from what I have found on other editors replace syntax but Id like some help on this too.
Totally ok with it being multiple passes to try get everything in the same format before the final update too.
im not adverse to using a different editor or somthing like a codemod (though I use windows)
To select all the strings that need modification use a RegEx Find
Find: ((?:v-bind)?:)([a-zA-Z0-9]+)([A-Z][a-z0-9]+)
Options: .* (RegEx) Aa (Match Case)
Use menu option Selection | Select All Occurrences.
When you have all selected that you want to change (including v-bind and :) you can use the following keybinding to replace the variable names to kebab case
{
"key": "ctrl+shift+alt+f8", // or any other keybinding combo
"command": "editor.action.insertSnippet",
"args": {
"snippet": "${TM_SELECTED_TEXT/([A-Z][a-z0-9_]+)/-${1:/downcase}/g}"
},
"when": "editorHasMultipleSelections && textInputFocus"
}
A Find replace with the following Regex is also possible
Find: ((?:v-bind)?:)([a-zA-Z0-9]+)([A-Z][a-z0-9]+)
Replace: $1$2-\L$3
Options: .* (RegEx) Aa (Match Case)
It can be used in Search Files Find-Replace.
You have to apply this Find-Replace multiple times, as many as there are Capital words in the variable with the most Capitals. The Find-Replace adjust the last Capital word of the variable name. Apply it again and it will adjust the now last Capital word. You can see in the Search Files if there are still conversions needed.
But for some reason VSC decides that capture group 3 are the last 2 characters of the variable name. If I test it on [regex101][1] (PCRE flavor to get `\L` recognised) the groups are captured correct, also if you select EcmaScript.
`$3` should start with a capital and VSC also finds a hit on `:prop`
I filed an issue for this
Thanks to Mark who pointed me that I was bitten by the Match Case trap. In programming the default is Match Case but in VSC the default is Ignore Case

Microsoft Word: Find and Replace Using Wildcards

Okay, So I know how to use the wildcard feature of 'Find and Replace' in Microsoft products. What I can't figure out is how to use the wildcards in my replacement text. Below is an example of what I want to accomplish.
I have a 92 page word document. I am trying to add color formatting quickly. The statement 'filling in page # - ITEM # factory or technical' appears 125 times throughout the document. the # after page ranges from 1-5 and the # after ITEM ranges from 1-25 for each page. I did a wildcard look-up to find everything, 'filling in page [0-9] - ITEM [0-9] factory or technical' but what I need to do is change the font color on all 125 occurrences from black to green. I know how to adjust all the formatting, I just don't know how to use the wildcard feature in the 'Replace with' field.
And perhaps this isn't possible. But I have multiple phrases that are similar that reoccur throughout this document and I was hoping to use the 'Find and Replace' feature to speed up this process. An

How to change lower case to upper using regular expressions in Visual Studio Code

I'm using Visual Studio Code 1.14.2, and I'm trying to change name of variables to camelCase eg.
set_nominal_wavelength to setNominalWavelength.
Regular expression: _([a-z])
Replace: \U$1\E
does not work. Any idea how to achieve it?
As of vscode v1.75 there is a Transform to Camel Case command. So you could
Find: (_[a-z]+)+
Alt+Enter will select all those
trigger the Transform to Camel Case command
Pretty easy.
In the 1.47 Insiders Build support for the replace case modifiers (\L, \l, \U, \u) has been added to vscode. And so should be in the 1.47 stable release).
So simply doing your find: _([a-z])
and replace with \u$1 (since you only want to capitalize the first letter) works nicely in the Insiders Build now.
Works in both the Find Widget and the Search Panel.
There is a workaround:
Open Replace dialog and enter regex: _([a-z])
Then move focus to the editor area and press Ctrl+F2 ("Change All Occurrences")
Then change case of selection (Ctrl+P >upper)
Then press Left Arrow key and press Delete key
You may use other tools that support change case operators, like Notepad++, sed, R (gsub with perl=TRUE), but VS Code does not support these operators in the replacement pattern.
See this feature request on GitHub:
This is cool to have. This is beyond the scope of what is currently supported by javascript.
We need to come up with our own advanced replace engine to support these cases.

Applying a Regex to a Rich text Box in Umbraco 7

I'm trying to apply a very simple regex to a Rich Text Box in Umbraco 7.
The regex I'm trying to apply is [^£\$].
I've tried some simple ones, [a-zA-Z], etc, but nothing seems to take effect.
Switching the property to as textString, and the regexes work immediately.
What am I doing wrong?
Thanks,
john
The point is that the rich text editor in Umbraco has various settings and it can show different types of content.
Regular expressions are used to find matches inside text data only.
Thus, setting the content type to textString for regex-based search to work is logical.
The fact that the regex box is not grayed out when a non-supporting mode is selected is most probably a minor bug.