Another REX Question

Post Reply
gerry.odea
Posts: 98
Joined: Fri Sep 19, 2008 9:33 am

Another REX Question

Post by gerry.odea »

I'm trying to rex a bunch of url strings like the ones below.
<$url=www.truecar.com/>
<$url=car.com/new-car-price>
<$url=www.carss.com>
<$url=car.prices.newcar.com>
<$url=car.newcar.net>
<$url=carsearch.com?site=www.cars.com>
<$url=www.carsearch1.com/?site=www.cars.com>

I'm trying to pull out only the website domains such as
truecar.com
car.com
carss.com
newcar.com
carsearch.com
carsearch1.com

I tried using <rex "[^.]+>>=" $url><$url=$ret> and it didn't work.

Also I tried using <urlutil split $url host> and that didn't work either.

Any ideas? Thank you.
User avatar
Kai
Site Admin
Posts: 1271
Joined: Tue Apr 25, 2000 1:27 pm

Another REX Question

Post by Kai »

$url is a reserved variable name in Vortex: printing it generates a self-referencing URL. So it should not be used for other purposes e.g. assignment.

Also, <urlutil split> requires a full URL, i.e. starting with a protocol. If you prepend "http://" to all of those URLs, and use e.g. $u instead of $url, then this code should work:

<urlutil split $u host>
<rex "[^.]+\.=[^.]+>>=" $ret>
Post Reply