Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I use lot of regular expressions. I'm using EditPadpro for all my editing purposes. Most of the time I'll have to extract all the regex matches in the file to another file. Is there any software that can do this?

Example:

While working with contacts file. I need to extract all email addresses to another file.

share|improve this question
add comment

5 Answers 5

up vote 5 down vote accepted

RegexBuddy, the sister product to EditPad Pro does this very nicely via it's Grep tab. Will recurse through folders and extract matches to a file. It's also great for building and testing regular expresions.

Use the settings as below:

  • You can add the pre-built email regex from the 'Library' tab
  • Make sure you select the 'Match' button on the top toolbar
  • Enter the file details on the 'Grep' tab and select 'Save results into a single file'

You can test the regex by pasting a section of your file into the 'Test' tab.

  • Press 'Execute' from the 'Grep' drop-down to run.

RegexBuddy screenshot

share|improve this answer
1  
I just downloaded it. But GUI seems to be pretty complex. Can you just tell me in 4 points. What do I need to do in regexbuddy to acheive what I want? –  claws Jul 11 '10 at 14:25
    
Damn it man! I'm probably the world's stupidest man alive. I was using PowerGREP instead of Regex Buddy. –  claws Jul 15 '10 at 19:49
add comment

I'm surprised that no-one noted findstr yet. It has at least rudimentary regular expression support with the /r switch and exists on every semi-recent Windows version (at least down to 2000).

share|improve this answer
1  
It's because almost no one ever hears about these fancy new tools. It almost seems as though Microsoft is actively trying to hide the command line or something... –  Ignacio Vazquez-Abrams Jul 11 '10 at 9:12
add comment

Install Cygwin, it will give you a very functional unix-like environment on windows. Then learn basic grep, egrep, awk, sed or perl. Time very well invested. Just a few examples:

# extract email addresses from text.txt to emails.txt
egrep -o '[[:alnum:].]+@[[:alnum:].]+' < text.txt > emails.txt
# extract third whitespace separated column from lines starting with "DEBUG"
awk '/^DEBUG/ { print $3 }' < text.txt > debug.txt
# replace multiple whitespace characters with one space
perl -pe 's/[\t ]+/ /g' < text.txt > clean.txt
share|improve this answer
add comment

Many Windows text editors (but not notepad) include "Find in Files" functions which support regular expressions.

PowerShell has Select-String which will do regular expression matching.

Or a Windows grep port.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.