Grep regular expression to get part of a line

Hi I just started on GNU Grep with regex and am finding it very challenging and need to ask for help already...

here is the problem, I have a page (MYFILE) which consists of the following....

<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTM3NjUMkY3RsMDM=" />
</div>

I want to Return the dynamic value on the __VIEWSTATE line.........

id="__VIEWSTATE" value="/wEPDwUKMTM3NjUMkY3RsMDM=" />

therefore expected result in this case would be......

/wEPDwUKMTM3NjUMkY3RsMDM=

I have been looking at

grep -o "(?<=__VIEWSTATE\" value=\")(?<val>.*?)(?=\")" myfile

Im not even sure if I need -o or not

However this returns nothing at all. Can you please help me to correct it ?

Many thanks in advance

awk -F"\"" '/VIEWSTATE/{print $(NF-1)}' yourfile
sed '/VIEWSTATE/!d;s/"[[:blank:]]*[^"]*$//;s/.*"//' yourfile
1 Like

very quick and accurate response, checked on awk and worked perfectly, many many thanks!