regex - Extract number embedded in string -


so run curl command , grep keyword.

here (sanitized) result:

...dir');">town / village</a></th><th><a href="javascript:setfilter(3,'listpublicasdf','asdfdir');">phone number</a></th></tr><tr class="rowodd"><td><a href="javascript:calldialog('asdf','&mode=view&hellothereid=42',600,800);"... 

i want number 42 - command line one-liner great.

  • search string hellothereid=
  • extract number right beside (42 in above case)

does have tips this? maybe regex numbers? i'm afraid don't have enough experience construct elegant solution.

you use grep -p (perl-regexp) parameter enabled.

$ grep -op 'hellothereid=\k\d+' file 42 $ grep -op '(?<=hellothereid=)\d+' file 42 

\k here job of positive lookbehind. \k keeps text matched far out of overall regex match.

references:


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -