DosCode Posted February 17, 2012 Posted February 17, 2012 I installed wingnu32 and perl and I try to run such command that should get Title from tags <title>Title</title>I am not sure, is it possible to run this program in cmd? Maybe I have wrong quoting? I tried few things1.for /f "delims=" %a in ('dir /b *.a') do (pcretest.exe -nle 'print $& if /(?<=title>).*(?=<\/title)/' < %a)2.for /f "delims=" %a in ('dir /b *.a') do (pcretest.exe -ln0e '$,="\n";print /(?<=<title>).*?(?=<\/title)/sg' < %a)3.for /f "delims=" %a in ('dir /b *.a') do (%a | pcretest.exe -nle 'print $& if /(?<=title>).*(?=<\/title)/')but I am getting error like: > not expected here...
Guest Posted February 17, 2012 Posted February 17, 2012 For all instances in CMD scripts, use %%a in place of %a.
DosCode Posted February 18, 2012 Author Posted February 18, 2012 (edited) For all instances in CMD scripts, use %%a in place of %a. Sure but this is not batch script, this is directy in CMD, so this %a is correct. Edited February 18, 2012 by DosCode
allen2 Posted February 18, 2012 Posted February 18, 2012 I wouldn't use pcretest there but sed from the unixtools:for /f "delims=" %a in ('dir /b *.a') do (type %a | sed.exe -n "s/<title>\(.*\)<\/title>/\1/Ip")
DosCode Posted February 18, 2012 Author Posted February 18, 2012 I wouldn't use pcretest there but sed from the unixtools:for /f "delims=" %a in ('dir /b *.a') do (type %a | sed.exe -n "s/<title>\(.*\)<\/title>/\1/Ip")Thanks. I didn't like sed because it seemed too hard to understand it, but this example with regex looks really simple and understandable.
Yzöwl Posted February 18, 2012 Posted February 18, 2012 Just make sure that you are searching for a title tag<Title>Required Title Text</TITLE>or a title with attribute tag<title="My Title">Required Title Text</TITLE>
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now