[[+content_image]]
N
N
niceteg2012-08-29 09:10:32
PHP
niceteg, 2012-08-29 09:10:32

How else to hide the URL in the text?

Greetings!

There are regular expressions with which the URL is cut out in the comments:

<?
$comment = eregi_replace(
                     '(((f|ht){1}tp://)[[email protected]:%_\+.~#?&//=]+)',
                     '[URL скрыт]', $comment);
$comment = eregi_replace(
                     '([[:space:]()[{}])(www.[[email protected]:%_\+.~#?&//=]+)',
                     '[URL скрыт]', $comment);
$comment = eregi_replace( 
                     'www.[[email protected]:%_\+.~#?&//=]+',
                     '[URL скрыт]', $comment);
?>

But only URLs that contain http and/or www are cut .

Prompt a regular expression to replace the URL of the form: exemple.com, exemple.net.ua or exemple.ru.

Thank you.

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
A
Andrey Burov, 2012-08-29
@niceteg

eregi - deprecated
can be something like this.

$text = preg_replace('/[a-z0-9\.]+(\.(ru|net|com))+/i','[URL скрыт]',$text);

G
Gleb Starkov, 2012-08-29
@colonel

What for?
Whoever needs it will write: example[dot]com

U
un_def, 2012-08-29
@un_def

Something like /[A-z0-9-.]?+\.(com|ru|net)/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question