How do I highlight a camelCase word in WebStorm? - webstorm

I am trying to highlight a camelCase word in WebStorm, For example, firstName.
However, It's doesn't highlight the entire word, highlight a portion of it, first or Name.
How can I select or highlight the entire word?
I am using WebStorm 2022.3 version.

Related

Match all spaces after a particular string

Doing a find and replace in VsCode on a large amount of files. I'm looking to replace all spaces after a set of quotes, but only on a specific line.
I can very easily find all spaces using \s+, but I don't understand how to capture only the spaces after a specific string(one specific line). I've tried positive look behinds, but I can only get it to match the first space, but I need to match all spaces on that line.
Example code:
variable = "01 - Testing this thing"
I need to find and replace all the spaces between the quotation marks with underscores, but I can't get any regex to match all the spaces between the quotes. I might want to replace the dash(-) as well, but the spaces are more important and I'm struggling to figure it out.
Here is a pretty good workflow.
Open a Search Editor (from the Command Palette or set a keybinding to it).
Use this regex (?<=variable = ")[^"]*.
That will find all matches in all files in your workspace or whatever folders you designate in the file to include filter. I suggest setting the context lines option to 0.
Ctrl+Shift+L to select all your matches. The matches are the 01 - Testing this thing part.
Now do a regular find in that search editor tab - with the Find in Selection option enabled.
Simply doing a find of and replaceAll with _ will make all those changes (in the Search Editor only).
To apply those changes to all the files with your initial search results, use the extension search-editor-apply-changes Apply Search Editor Changes... command.
Then you can check to see if the changes were as you expected and save all. It will open all affected files so you can inspect them.
Seems like a few steps but notice the first regex can be very simple. And then you are doing a simple find/replace in just those selections. Demo:
You search for a string that matches, it has A space between the quotes. Replace with what is before and after the space but the space is now an underscore. You have to apply this as often as the max number od spaces in a string. It can't be done in 1 regex search-replace.
In the Search Bar
Find Regex:
(variable = "[^" ]*) ([^"]*")
Replace:
$1_$2
Then apply Replace All (button) and Refresh (button) until no more searches found.

Notepad++ highlighting anything between two square brackets

I have a document containing a series of strings between hundreds of [] and I want to highlight the strings and copy the information into a spreadsheet.
I have attempted using the Find tool but cannot figure out the regex expression
The final goal of this would be to be able to copy the information in one go into a new file, or highlight it and copy into an excel spreadsheet.
Text file something like:
>X_343435353.3 words like foo bar [Wanted text]
TGATGATGCCATGCTAGCCATCGACTAGCGACTAGCATCGACTAGCATCAGCTACGACTAGCATCGACTACGA
>XP_543857836.3 other information [Text that I want]
TAGCATCGACTAGCTACTACCTGAGCGAGAAATTTTGGCTATCGACATCGACTATCGAGCACAGCTAGGAATT
>NP_3843875938.2 interesting words [Third desired text]
ATCGCATAGCGCGCTTAGAAGGCCTTAGAGGCATCATCTATCGAGCGACGATATCGCGAGGCAGCGCTATACC
The ouput I desire is as follows:
Wanted text
Text that I want
Third desired text
I am not sure if it is possible to do this in Notepad++ or if you need to use a cmd/shell tool to do it. I am using a Windows 10. The thought was that it may be possible to highlight all of the desired text with a regex that can then be copied elsewhere.
To match just the text and not the brackets:
(?<=\[).*?(?=\])
Example:
To delete everything in a document and leave just the wanted text on each line:
Set the cursor at the start of the document.
Macro, Start recording.
Ctrl-F (Find), .*?\[, Select regular expression and . matches newline.
Click Find Next and close the dialog.
Delete the highlighted text.
Ctrl-F (Find), \], Select regular expression and . matches newline.
Click Find Next and close the dialog.
Hit Enter to delete the highlighted text.
Macro, Stop recording.
Macro, Run a macro multiple times, select Until end of file.
Click Run.
Result:
Wanted text
Text that I want
Third desired text
You'll need to delete the last bit after the final match (if any) once the macro completes.
Maybe this expression,
.*\[(.*?)\][\s\S]+?([\r\n]|$)
with a replacement of $1\n also might work.
The expression is explained on the top right panel of this demo if you wish to explore/simplify/modify it.
This one is working fine for me ....
Find what: >.*?\[(.*?)\]\n.*
Replace with: $1

Select specific text in specific column of CSV with variable text length

I'm working on a CSV file in Notepad++, and I need to match a specific occurance of a set number of characters in the text. Example data:
19256506_1.MSG,19256506,1.MSG,RE: New Consent Language,
19256505_1.MSG,19256505,1.DOCX,RE: New Consent Language,
19256433_1.MSG,19256433,1.MSG,RE: New Consent Language,
What I need to select is the file extensions in the 3rd row, leaving only the number. The problem is, it could either be .MSG, .DOCX, .PDF, etc. Basically, I need to select anything in the 3rd column after and including the ., but up to and excluding the next ,.
How can I match this using regex?
You could use
^[^,]*,[^,]*,[^.,]*(\.[^,]+)
Use the first group, see a demo on regex101.com.
Press ctrl + h (or Search > Replace) and try replacing:
(?s)^(?:[^,]*,){2}[^,]*(\.[^,]+).*?$
With
\1
Make sure Search Mode is set to Regular Expression
Hit Replace All
Demo

Limit g flag in regex substitution to part of line?

I have a file like this:
"File_name_1.dat" "File_name_1.dat"
"File_name_2.dat" "File_name_2.dat"
"Some_other_thing.dat" "Some_other_thing.dat"
Is there a regex technique can I use to replace the underscores in only the second file name on each line, like this?
"File_name_1.dat" "File name 1.dat"
"File_name_2.dat" "File name 2.dat"
"Some_other_thing.dat" "Some other thing.dat"
I tried matching the column (\%XXc in Vim), but it seems to disable the g flag.
This only replaces the first underscore after column 25:
:%s/\%25c\([^_]*\)\zs_/ /g
This only replaces the last underscore in the line:
:%s/\%25c\(.*\)\zs_/ /g
I know I could repeat that command until they're gone, but I was wondering if there is a slicker way to do it.
Yes, there is an easy way to do this with visual selections. It's convenient that your data is layed out nicely, otherwise this wouldn't work.
Visually select all of the second filenames
Run this regex:
:'<,'>s/\%V_/ /g
The \%V will restrict your substitute to the inside of the current visual selection. Here's a screen shot of what I mean:
There are probably many ways to do this. Since the data is formatted nicely I would probably visually select and delete the first column (with <c-v>), Then run :%s/_/ /g. Then paste back the first column.
If you really wanted to do this in a single regex, you would need to use a lookbehind
:%s/\(\%25c.\{-}\)\#<=_/ /g
Where \#<= matches if the preceding element matches. :help \#<=

Notepad++ Regex inverse match

I'm new to Regex and trying to figure out how to remove all text from file open in Notepad++ that does not match #LCxxxx or #LAxxxx. Example below (text wanting to keep in bold):
1.In rare cases, reinstalling this MSP file can cause the Citrix Display Driver.....
[From ICAWS760WX86][#0528688]
30.This release includes an enhancement...
[From ICAWS760WX86022][#LA3014]
New Fixes in This Release
1.Windows Server 2008 R2 and Windows Server 2012 R2,...
[From ICAWS760WX86026][#LC2179]
Fixes from Replaced Hotfixes
1.If the Windows Remote Desktop Session Host....
[From ICAWS760WX86004][#LC1180]
I think this is what you're looking for:
(?:[\S\s]*?)(\#L[AC]\d{4})(?:.*)
Replace with:
$1\n
You could do a regular expression search and replace, searching for
(#L[AC]....)
where "dot matches newline" is NOT selected. Replace with
\r\n\1\r\n
That will put all the wanted pieces of text on a line on their own.
Next use the "Mark" tab in the find window. Select "Bookmark line", use the same search string as above (the capture brackets are not needed this time, but they are harmless and so can be left), and them click "Mark all". Now all the wanted lines are bookmarked. Use menu => Search => Bookmark => Remove unmarked lines.
There may be a way of doing it all in one go, but that would be a complex regular expression. The method above uses two simple steps.
remove all text from file open in Notepad++ that does not match #LCxxxx or #LAxxxx
^.*(\[#L[CA]\d+\])$|^.*$
DESCRIPTION
DEMO
https://regex101.com/r/hO1aL8/2
Notepad++
Do a search and replace like describe in the screenshot below:
Alternatively, if you want to get rid off the empty lines during the replace operation, use the regular expression below:
^[\S\s]+?(\[#L[CA]\d+\])$
\s : Whitespaces (\t,\r,\n ...)
\S : Any character except whitespaces.
Tested on Notepad 6.6.9