A message for Linux.com registered users: We are in the process of making changes to the Linux forums. Starting Monday, 8/13/18 at 6:00 PM PT, you will be unable to access the forums. They will re-launch as soon as possible on Wednesday, 8/15/18 with new features and improved functionality. Thank you for your patience and stay tuned for the new improved forums.

fux
April 29, 2013

help on regular expression

Forums: 

hi,
I want to extract some URLs of a txt file with grep --only-matching and regular expression.

I know only some info about the URL, but I definitely know by what it is enclosed.
Example:
AA"$URL"BB

so I use grep -o AA.*BB myfile.txt

But this gives my whole expression (i.e. AA"$URL"BB), but I only want the URL i.e. what is enclosed by AA and BB, how do I do that?

Thanks.

Click Here!