Basically every line in my text file is formatted like this:
1) Baker
2) Photographer
3) Doctor
4) Teacher
5) CEO
etc, etc.
Using Notepad++ how do I remove the 1), 2), 3), etc?
1 ) Press Ctrl + H for pop window to Replace.
2 ) Provide the ^\d+\) regular expression in Find what text field, choose option Regular expression in search mode and make empty in Replace with text field.
3 ) Click on Replace all or Replace button.
You can use the regex ^\d+\) (note the trailing whitespace) and replace text matching this pattern with an empty string.
Step-by-step guide:
Press Ctrl+h to open the Replace dialog.
Press Alt+F to focus on the Find text field.
Enter ^\d+\) and press Alt+l to switch to the Replace with text field.
Press backspace to delete any text that might be in this box.
Press Alt+g to switch the search mode to regular expression.
Press Alt+a to perform a replace all operation on the document.
You can use the column selection mode, normally accessed with alt + mouse, or by the edit menu, select the 2 columns, and delete them as any text
Related
Simple question: I am looking for the shortcut in WebStorm to select all the occurrences of a word and then replace them
e.g in my CSS file I want to select all the 'phone' variables at once and change them to 'tab-port'
Use Ctrl+ R for find and replace. This will open up a dialog at the top of the file that will look similar to the following: (depending on your IDE theme)
If you want to select all occurrences directly in the code, you can select all of them with the next shortcut:
Ctrl + Cmd + G on Mac OS X or
Ctrl + Alt + Shift + J on Windows
If you want to replace all occurrences, you can make as chazsolo said.
I have a file with some data as follows:
795 0.16254624E+01-0.40318151E-03 0.45064186E+04
I want to add a space before the third number using search and replace as
795 0.16254624E+01 -0.40318151E-03 0.45064186E+04
The regular expression for the search is \d - \d. But what should I write in replace, so that I could get the above output. I have over 4000 of similar lines above and cannot do it manually. Also, can I do it in python, if possible.
Perhaps you could findall to get your matches and then use join with a whitespace to return a string where your values separated by a whitespace.
[+-]?\d+(?:\.\d+E[+-]\d+)?\b
import re
regex = r"[+-]?\d+(?:\.\d+E[+-]\d+)?\b"
test_str = "795 0.16254624E+01-0.40318151E-03 0.45064186E+04"
matches = re.findall(regex, test_str)
print(" ".join(matches))
Demo
You could do it very easily in MS Excel.
copy the content of your file into new excel sheet, in one column
select the complete column and from the data ribbon select Text to column
a wizard dialog will appear, select fixed width , then next.
click just on the location where you want to add the new space to tell excel to just split the text after this location into new column and click next
select each column header and in the column data format select text to keep all formatting and click finish
you can then copy all the new column or or export it to new text file
I've recently moved from Sublime Text 3 to WebStorm 11 and I am missing a key feature when selecting occurrences of the same selection:
The ability to skip a selection (with a hotkey).
Use case
const item = { itemValue: 1, itemName: 'one' };
console.log(item.itemValue);
Selecting the first item and pressing Ctrl + G (Mac) will start selecting the item occurrences inside the object properties, and I want to select only the item right after the const and inside the console.log. Essentially, I want to skip the two item occurrences inside the object.
This is a dummy use case to illustrate the point, I know I can Refactor > Rename it.
Highlight the text you want to edit:
Ctrl+G will find the next occurrence of the highlighted text and select it:
Cmd+G will drop the current selection and select the next one:
Cmd+G one more time will drop the current selection and select the next one:
For anyone that has a different Keymap:
Cmd+G: "Find Next / Move to Next Occurrence"
Ctrl+G: "Add Selection for Next Occurrence"
Right now, the only solution I found is using Find:
Select the text and press Cmd + F (the find bar will open with the selected text as a search)
Press Cmd + G to select the next occurrence
Press Enter to skip it (will select the next occurrence)
Press Enter again
Press Esc to exit the find context
And now the desired items are selected and ready for editing.
At least it's doable, but I'd expect a hotkey to just skip the current occurrence.
How can I use regular expression in excel ?
In above image I have column A and B. I have some values in column A. Here I need to move data after = in column B. For e.g. here in 1st row I have SELECT=Hello World. Here I want to remove = sign and move Hello world in column B. How can I do such thing?
Stackoverflow has many posts about adding regular expressions to Excel using VBA. For your particular example, you would need VBA to actually move a substring from one cell to another.
If you simply want to copy the substring, you can do so easily using the MID function:
=IFERROR(MID(A1,FIND("=",A1)+1,999),A1)
I used 999 to ensure that enough characters were grabbed.
IFERROR returns the cell as-is if an equals sign is not found.
To return the portion of string before the equals sign, do this:
=LEFT(A1,FIND("=",A1&"=")-1)
In this case, I appended the equals sign to A1, so FIND won't return an error if not found.
You can use the Text to Column functionality of MS-Excel giving '=' as delimiter.
Refer to this link:
Chop text in column to 60 charactersblocks
You can simply use Text to Column feature of excel for this:
Follow the below steps :
1) Select Column A.
2) Goto Data Tab in Menu Bar.
3) Click Text to Column icon.
4) Choose Delimited option and do Next and then check the Other options in delimiter and enter '=' in the entry box.
5) Just click finish.
Here are URL for Text to Column : http://www.excel-easy.com/examples/text-to-columns.html
I'm looking for a way to replace "&" from a text string when it's followed by text. For example;
Input Text: "Ne&w && Edit Record"
Required Output: New & Edit Record"
The reason for "Ne&w" is that "&" then shows w as the shortcut key (underscored in the UI) and the reason for the "&&" is so that a single "&" is displayed in the text.
When using the input text as the value for the text propery on a command button the text displays as expected, but when I pass the text property to a message box it displays the input text in the message box dialog.
I don't want to use the Tag property to store the message I want in the message box as I use the tag property for another value.
Try this:
Dim input As String = "Ne&w && Edit Record"
Dim output As String = "New & Edit Record"
Dim p As String = Regex.Replace(input, "&(?<first>\w|&)", "${first}")
MessageBox.Show(output = p) 'shows True
In the above Regex expression I am capturing an ampersand followed by either a letter or another ampersand, and replacing that sequence with a symbol coming after the ampersand. <first> is a named group, it is used for Regex replacement.
See Regex.Replace on MSDN.
You can remove all & signs not followed by a & sign. Match them like this:
&(?!&)
See it in action