Is it possible to extract emails from a csv using a dos/cmd batch file? -
i have csv file 1m email addresses , need extract them csv text file.
i googled , found few links, , found, didn't trick.
so possible extract emails csv using dos/cmd batch file? , possible linux saddly i'm have use windows.
set arg = wscript.arguments set wshshell = createobject("wscript.shell") set inp = wscript.stdin set outp = wscript.stdout 'remove ^ quoting command line. quote, ampersand , brackets pttn = replace(arg(2), "^(", "(") pttn = replace(pttn, "^)", ")") pttn = replace(pttn, "^&", "&") pttn = replace(pttn, "^""", """") set regex1 = new regexp if instr(lcase(arg(1)), "i") > 0 regex1.ignorecase = true else regex1.ignorecase = false end if regex1.global = false regex1.pattern = pttn until inp.atendofstream line=inp.readline line = regex1.replace(line, arg(3)) outp.writeline line loop
to use
cscript //nologo "c:\path to\scriptname.vbs" < inputfile.txt > outputfile.txt
replace
filter replace {i|n} expression replace filter repl {i|n} expression replace
finds , replaces text using regular expressions.
also used extract substrings file.
ampersands , brackets in expression must escaped caret. not escape carets. use hexidecimal code \x22 quotes.
searchoptions
i - ignore case n - none
expression
regular expression reference
replace
the text replace. use $1, $2, $..., $n specify sub matches in replace string
example
filter replace "=" "no equal sign" < "%systemroot%\win.ini"
this searches text within square brackets , replaces line cat followed text within brackets
filter replace "^\[^(.*^)\]" "cat$1" < %windir%\win.ini
this searches text , prints 11th character end of line.
filter replace "^.{10}^(.*^)$" "$1" < %windir%\win.ini
this searches csv file , prints second , fourth field
filter replace "^.+,^(.+^),.+,^(.+^)$" "$1,$2" < csv.txt
try regex (there thousands on internet http://www.regular-expressions.info/email.html)
[0-9a-za-z]+\.?[0-9a-za-z]?@[0-9a-za-z]+\.com|org|net|gov
Comments
Post a Comment