Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find and Replace in Notepad++ using Regular Expression

I got a numeric list. One number per line. I want to replace all numbers with a specific pattern. For example, my file look like this:

1
2
3
4

I want to replace it so as to look like the following using a regexp in Notepad++:

[1],
[2],
[3],
....
like image 709
esquare Avatar asked Apr 30 '11 09:04

esquare


People also ask

How do I Find and replace in Notepad?

Open the text file in Notepad. Click Edit on the menu bar, then select Replace in the Edit menu. Once in the Search and Replace window, enter the text you want to find and the text you want to use as a replacement. See our using search and replace and advanced options section for further information and help.

How do you replace regex in Notepad?

In all examples, use select Find and Replace (Ctrl + H) to replace all the matches with the desired string or (no string). And also ensure the 'Regular expression' radio button is set. Check that your word wrap is switched off so that you actually see the text get modified.

Can you use regex in Find and Replace?

When you want to search and replace specific patterns of text, use regular expressions. They can help you in pattern matching, parsing, filtering of results, and so on. Once you learn the regex syntax, you can use it for almost any language. Press Ctrl+R to open the search and replace pane.

How do I search for a Regular expression in Notepad++?

1.3, doing any of those keystrokes ( Ctrl+F , Ctrl+H , Ctrl+Shift+F , or Ctrl+M ) once would open the Find dialog or bring it into focus; from the main dialog, hitting Ctrl+F would re-center the dialog (no matter which tab of the dialog you were on); but you could not use the shortcuts for the other tabs to switch ...


1 Answers

Find what:

([0-9]+)

Replace with:

[\1],
like image 156
cnicutar Avatar answered Sep 29 '22 08:09

cnicutar