Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6120001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:37:05+00:00 2026-05-23T15:37:05+00:00

I am using Ubuntu 10.10 and using Grep to process some HTML files. Here

  • 0

I am using Ubuntu 10.10 and using Grep to process some HTML files.

Here is the HTML snippet:

<a href="video.php?video=one-hd.mov"><img src="/1.jpg"><a href="video.php?video=normal.mov"><img src="/2.jpg"><a href="video.php?video=another-hd.mov">

I would like to extract one-hd.mov and another-hd.mov but ignore normal.mov.

Here is my code:

example='<a href="video.php?video=one-hd.mov"><img src="/1.jpg"><a href="video.php?video=normal.mov"><img src="/2.jpg"><a href="video.php?video=another-hd.mov">'
echo $example | grep -Po '(?<=video.php\?video=).*?(?=-hd.mov">)'

The result is:

one
normal.mov"><img src="/2.jpg"><a href="video.php?video=another

But I want

one
another

There is a mismatch there.

Is this because of the so-called Greedy Regular Expression?

I am sing GREP but any command line bash tools are welcome to solve this problem like sed etc.

Thanks a lot.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:37:06+00:00Added an answer on May 23, 2026 at 3:37 pm

    You want use Perl regexes for grep – why not directly perl?

    echo "$example" | perl -nle 'm/.*?video.php\?video=([^"]+)">.*video.php\?video=([^"]+)".*/; print "=$1=$2="'
    

    will print

    =one-hd.mov=another-hd.mov=
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using ubuntu and I have some html pages. I want to host
I'm using Ubuntu 8.10 (Intrepid Ibex) and compiling C++ files with GCC, but when
I want to use PDT to debug PHP with eclipse. I am using ubuntu
i am using ubuntu and i have a html page named first.html at home/sanu
I am using ubuntu 11.04 and when I am opening terminal and typing php
I am using ubuntu. There are some processes that are doing io frequently on
I am using ubuntu, fluxbox, pcmanfm as filemanager, xmms2 as music player. My goal:
I am using Ubuntu 9.04 I have installed the following package versions: unixodbc and
I am using Ubuntu 9.04 I just installed ruby and rails in my system
I am using Ubuntu 9.10 beta, whose repositories contain boost 1.38. I would like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.