I have a link and I would like to return only content between www. and .com
www.blablabla.com would return only
How could I do that? When I use
grep '\.[a-zA-Z0-9\.-]*\.' it gives me
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
$ echo "www.blablabla.com" | grep -oP '(?<=\.)[a-zA-Z0-9\.-]*(?=\.)' blablabla
-o -- print only matched parts of matching line
-P -- Use Perl regex
(?<=\.) -- after a literal
., aka, a "positive look-behind" ...
[a-zA-Z0-9\.-]* -- match zero or more instances of lower & upper case characters, numbers 0-9, literal
. and hyphen ...
(?=\.) -- followed by a literal
., aka a "positive look-ahead"