Reputation: 19
im trying to print the content of a html table cell.
i thought the easiest way to do this was with grep, but for some reason the regex works on regexr.com but not within Grep.
Maybe something with escaping? i tried escaping al the smaller and larger than <> symbols.
This is the code i'm using
wget -q -O login.html --save-cookies cookies.txt --keep-session-cookies --post-data 'username=sssss&password=fffff' http://ffffff/login
wget -q -O page.html --load-cookies cookies.txt http://ffffff/somepage |grep -P '(?<=<tr><td class=list2>www</td><td class=list2 align=center>A</td><td class=list2 >)(.*?)(?=</td><td class=list2 align=center><input type=checkbox name=arecs5)' |recode html...ascii
Can anybody help me please? I'm from the netherlands so sorry for my english.
i aslo tried adding the -c option and it printed 0
EDIT:
Added my full code, i found 1 mistake. i didn't have the -O parameter to output the page's html. but it still doesnt work. it prints nothing
Upvotes: 0
Views: 887
Reputation: 19
Finally, it works. I added -qO- to wget, i don't know why but when adding a - after the -O it works.
Upvotes: 0
Reputation: 785146
Traditional grep
doesn't support lookarounds the way you're using it.
Try using grep -P (PCRE)
:
grep -P 'pattern' file
Upvotes: 1