Tag Info

Hot answers tagged


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


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', ...


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 ...


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 ...


: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 ...


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 ...


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 ...


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 ...


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


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.


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' '{}' +


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


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 ...


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.


In the "Find and Replace" dialog box click the "Options >>>" button and change the "Within" drop down from "Sheet" to "Workbook".


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. ...


Go to Find (Ctrl + F) -> tab Replace -> click More... -> Special -> End of paragraph. The symbol is ^p. You can use it in both directions. I have MS Office 2007, but it should work in older versions too.


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


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>.


In the Replace dialog (Ctrl+H), use the following: Find what: %(.+)% Replace with: $\1 Search Mode: Regular expression


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 ...


"It Depends." You'll probably need a couple things: First of all, the text can't have been rasterized. If that's the case, then all bets are off. Second, the entire font must have been embedded. If the font was subsetted (which is most often the case) then you may not have the required glyphs. Finally, you'd probably want to limit the size of the ...


Yes. Use the g command to operate on lines matching a pattern, along with the d command to delete those lines. g/pattern/d So: g/\\\(begin\|end\){frame}/d should do the trick. If that doesn't work, try: :g/\v\\(begin|end)\{frame\}/d which will work, no matter what your magic setting is.

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