Tag Info

Hot answers tagged


You can use regular expressions by clicking on this button: The regex for a Tab character is \t.


This command will do it (tested on both Mac OS X Lion and Kubuntu Linux). # Recursively find and replace in files find . -name "*.txt" -print0 | xargs -0 sed -i '' -e 's/foo/bar/g' Here's how it works: find . -name '*.txt' finds, in the current directory (.) and below, all files whose names end in .txt | passes the output of that command (a list of ...


I don't think your files are corrupted. Your example line looks like it contains regular text with null bytes between each character. This suggests it's a text file that's been encoded in UTF-16 but the byte-order mark is missing from the start of the file. See http://en.wikipedia.org/wiki/Byte-order%5Fmark Suppose I open Notepad, type the word 'filename', ...


You can use :%g!/price/d to delete every line that doesn't contain "price"


Find and Replace (CTRL + H) Search for ~* Replace with whatever. Cheers!


You could try: %s/<CTRL-2>//g (on PC) %s/<CTRL-SHIFT-2>//g (on Mac) where <CTRL-2> means first press down the CTRL on PC, keeping it as pressed down, hit 2, release CTRL. and <CTRL-SHIFT-2> means first press down the control on Mac, keeping it as pressed down, press down shift on Mac, keeping it as pressed down, hit 2, release ...


Within notepad there is no way to use the Find and Replace and target blank lines. Consider Notepad++ and the regex search and replace. You can use \r\n to find blank lines from text files made within Windows, \r for Mac and \n for Linux. I believe a default install actually comes with TextFX to make your life even easier, it has an option to delete blank ...


:g/pattern/ matches all the lines were pattern is found. :v/pattern/ does the opposite. See :h global for more details. You can use it like this: :v/pattern/norm Ipattern not found - <CR> to prepend "pattern not found - " to every line that doesn't have "pattern" or :v/pattern/s/nrettap/pattern to replace "nrettap" with "pattern" on every ...


This actually worked for me within vim: :%s/\%x00//g


Please make sure you have a backup in case something goes wrong. In Notepad++ go to Search → Replace In the Find What textbox paste the following: youtubehd:\w\w\w\w\w\w\w\w In the Replace With textbox paste the following: youtubehd Ensure that Search Mode is set to Regular expression Click Replace All Thanks to KCotreau for pointing out that search ...


grepWin (not to be confused with Windows Grep) can do this. It supports text-based search and replace, as well as regular expression search and replace: grepWin is free and open source.


vbScript should do it for you. Create a file called "rename_underscores.vbs" containing the following. Set objFso = CreateObject("Scripting.FileSystemObject") Set Folder = objFSO.GetFolder("c:\test\") For Each File In Folder.Files sNewFile = File.Name sNewFile = Replace(sNewFile,"_"," ") if (sNewFile<>File.Name) then ...


According to Helixoft: Multiline Search and Replace in Visual Studio you can enable Regular Expressions and then use \n to indicate a new line.


Notepad++ allows you to use capture groups in the search regex, and then refer to those in the replacement. so, use the search term ([0-9])\t([0-9]). The parentheses tell Notepad++ to "capture" the part of the text that matches that part of the regex - in this case, the numbers before and after the tab. In your replacement expression, refer to those ...


At the bottom of the search/replace window you can select the search mode "regular expression", then you can search for CoverLevel="\d\d" the \d means any number, in a regular expression. This searches for two numbers, if you want to search for "one or more numbers" you can use the + quantifier "\d+"


Take a look at Sed. You can easily achieve your goal by only one command line sed -e "s/Text_1/TextA/" -e "s/Text1/TextB/" <your_file.txt>your_file_new.txt


Yes you can, I just tried to record a new macro, did a search and replace and it succesfully saved the action so when I played the macro, it did the same search and replace action. I am not an expert at Notepad++ Macros, but I am guessing you are... I opened a random file and created a macro called test. It looked for a word called "snip" and replaced it ...


Use the "Extended" setting in the Replace window (not "Regular expression": I'm sure there's a way to do it with Regular expression, but using "Extended" works fine). Enter ".pPrev.\r\n" in the "Find what" field, and leave the "Replace what" field blank. This will include the \r\n characters in the match and delete the whole line.


I've written a free command line tool for Windows to do this. It's called rxrepl, it supports Unicode and file search. Some may find it a useful tool. rxrepl is a Microsoft Windows command line tool to search and replace text in text files using Perl compatible regular expressions (PCRE). It has the following features: Search using Perl ...


This would delete all lines that don't contain foo. :g/^\(.*foo\)\@!.*$/d Instead, you could also use :v to reverse the sense of search pattern. :v/\(foo\)/d You can read more about the way :g and :v work here. And more on defining ranges, use of metacharacters etc. for search and replace here.


Yes, you can. See :help sub-replace-special; the \= allows you to replace with a Vim expression. And system() can execute an external command and return its output. See my trivial example with hostname. Note that I had to use substitute() to get rid of the trailing newline character(s) in the output. ...


I'd use Perl for this: perl -0pe 's/<h1>Title.*\n.*<br>/replacement/' filename.html Here, -0 makes Perl split records on the NUL character instead of reading line-by-line, which is the default when using the -p option. With Perl regular expressions you need .* to match any character multiple times, and you match the newline with \n. ...


The short answer: Yes, but it's harder than you think. The long answer: Ordinary find-and-replace code operates on a morphological level, that is, by looking at the form of a text rather than by understanding its meaning. But there is no morphological indication to differentiate the objective and possessive cases of the third-person female pronoun, so ...


With your sample text in a file named sql, the following pattern: $ sed 'N; s/,\n FULLTEXT.*//' sql produces: CREATE TABLE `table` ( `id` int(10) NOT NULL auto_increment, `name` varchar(100) NOT NULL default '', `description` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = ...


Fairly basic. Use sed with file globbing. Unless you mean every file in directory and subdirectories? sed -i 's/string1/string2/g' /path_to_dir/* Edit: In the case of literally everything under the directory find /path_to_dir/ -type f -exec sed -i 's/string1/string2/g' '{}' +


How do I replace any number of spaces using regular expressions Notepad++ Solution To match one or more space characters: Set "Find what" to + (space followed by +) To match one of more whitespace characters (space, EOL, and tab all count as whitespace): Set "Find what" to \s+ Warning: Using \s+ will match end of line and therefore join multiple ...


On Windows a linebreak consists of two characters: carriage return and line feed, so you have to search for \r\n</li> and replace with just </li>.


The Scripting Guy covers how to do this in PowerShell (no additional downloads on most recent Windows OSs, you probably already have it installed). Start it up, run the following (to replace a * with a @): (Get-Content C:\Scripts\Test.txt) | Foreach-Object {$_ -replace "\*", "@"} | Set-Content C:\Scripts\Test.txt This supports .NET regular expressions, ...


\b(?:(T)|t)own(s?)\b → (?1:\u)village$2 (And uncheck ignore case in the dialog) \b = word boundary (?:) = non-capturing group (?1:\u) = if captured group 1 then convert next character to uppercase


You could try VBA Find & Replace. VBA Find and Replace© provides a method for finding and replacing text anywhere in a document (or collection of documents) using single user defined "find" and "replace" variable pairs, or a user defined list of "find" and "replace" pairs. It also provides a method to find text and replace found text with a user ...

Only top voted, non community-wiki answers of a minimum length are eligible