S
S
Sergey2015-09-16 21:37:02
Regular Expressions
Sergey, 2015-09-16 21:37:02

How to block domains in linux?

How (in the easiest way) to block access to sites with obscene content?
PS I know about iptables, but maybe there is an option without manually knocking out url-s?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
DanKud, 2019-04-21
@dzedzinskiy

Specifically for this line, you can do this:

$str = '~astbbhf_sg_fasgs~3.6.0=SOME_OTHER_STRING.~phase2~3.6.0=OLD';
preg_match('/someflag.*=(.+?)\./i', $str, $m);
$result = $m[1];

accordingly, if there are no matches, then it $resultwill be equal tonull

V
vreitech, 2019-04-22
@fzfx

^(~[A-Za-z]+_(someflag.*?=(.+?)\.~.*|.*)|.*)
for example, the command for bash using perl is:

echo '~astring_someflag_xds~2.37.0=NEEDED_STRING_TO_EXTRACT.~cha_khe_mil~2.22.0=TADA' \
| perl -pe 's/^(~[a-z]+_(someflag.*?=(.+?)\.~.*|.*)|.*)/\3/i'

well, or as a script on the same perl:
$_='~astring_someflag_xds~2.37.0=NEEDED_STRING_TO_EXTRACT.~cha_khe_mil~2.22.0=TADA';
s/^(~[a-z]+_(someflag.*?=(.+?)\.~.*|.*)|.*)/\3/i;
print;

for php it would probably be something like:
$str = '~astring_someflag_xds~2.37.0=NEEDED_STRING_TO_EXTRACT.~cha_khe_mil~2.22.0=TADA';
preg_match('s/^(~[a-z]+_(someflag.*?=(.+?)\.~.*|.*)|.*)/i', $str, $m);
print($m[3]);

F
Fixid, 2015-09-16
@DrMGC

Yandex Family (register DNS)
77.88.8.7
77.88.8.3
Without adult sites

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question