February 17, 201214 yr 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...
February 18, 201214 yr Author 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, 201214 yr by DosCode
February 18, 201214 yr 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")
February 18, 201214 yr Author 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.
February 18, 201214 yr 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>
Create an account or sign in to comment