I think I understand what you mean. I made a solution in PHP, but I can use the same logic in another language. These /../
means that the URL suffers a shortening, and the content removed is where the points are. Example:
link
Could be shortened to link . This reduces the size of the "phrase" but still retains the original address by clicking on it. You can reproduce the same effect.
I created a regular expression that takes the content between the first bar and the last URL bar (% with%). After that I simply used /../
to get the REGEX result and created a new variable with the new address. With both addresses at hand (the original and the shortened), we can create a preg_match_all
tag the way you want it. See the code:
<?php
// URL de exemplo
$url = "http://www.exemplo.com/categorias/jogos/veja-as-incriveis-novidades-de-2015";
// Aplica o Regex na URL
preg_match_all('/[\da-z\.-]+\/(.+)\//', $url, $url_match);
// Pega o resultado do Regex
$new_url = str_replace($url_match[1][0], "..", $url);
// Cria um elemento <a> com nossas URLs.
$element = "<a href='$url'>$new_url</a>";
// Imprime o resultado na página
echo $element;
See working on Ideone: link
In a page running PHP, the result will be this (notice that clicking on the link the original address that is opened):
<a href='http://www.exemplo.com/categorias/jogos/veja-as-incriveis-novidades-de-2015'>http://www.exemplo.com/../veja-as-incriveis-novidades-de-2015</a>