Regexp seems great but how do I output the result?
March 31, 2008 8:28 AM   Subscribe

I have a found out a regular expression that searches for a specific bit of text i want to extract from a html document (product names) in notepad++. Now i want to put all the matches of my expression in a new file. Can this be done?

I tried using the macro recorder but didnt manage to find a solutions since it always go back to the first match. I also tried cygwin grep but never got it to work (I typed "grep 'expression' file" but it returned the whole lines, not only the match).

I also have excel if it will help.
posted by ilike to Computers & Internet (3 answers total)
 
Best answer: the -o switch to grep will do want you want. From the manual:

-o, --only-matching
Show only the part of a matching line that matches PATTERN.
posted by tallus at 8:58 AM on March 31, 2008


Do all greps have that function? Mine doesn't seem to.

Anyway, the second part with the "put all matches into a new file" can be done like this:

grep whatever *.html > results.txt

which will redirect your output to the file.

Have you got Perl, by the way?
posted by AmbroseChapel at 5:53 PM on March 31, 2008


its probably a gnu vs bsd thing. AFAIK cygwin is gnu based though.
posted by tallus at 10:03 AM on April 1, 2008


« Older Eclipse as a Code Browser   |   Need appletv, have windows :( Newer »
This thread is closed to new comments.