sed uses basic and extended regular expressions (BRE/ERE). .*? is part of a Perl Compatible Regular Expression (PCRE).
To use PCRE, use perl:
$ perl -pe 's/<a.*?href="(.*?)".*?>(.*?)<\/a>/[\2][$2](\1$1)/g' test
on [reddit](https://www.reddit.com/) or [Lifehacker](https://lifehacker.com/)
- This is exactly the same expression as the original, but used with
perl -pwhich reads &and prints file line by line – likeseddoes.
Here is a similar regex using ERE with sed:
$ sed -E 's/<a[^>]*href="([^"]*)[^>]*>([^<]*)[^>]*>/[\2](\1)/g' test
on [reddit](https://www.reddit.com/) or [Lifehacker](https://lifehacker.com/)
- PCRE uses a
?following a quantifier to match the shortest repetition, standard regular expressions do not - Negated character classes are used to work around this