$text = '
<p>one</p>
<p>two</p>
<p>three</p>
';
$text = preg_replace('#<p>.*?three.*?</p>#i', '', $text);
echo $text;
$text = '
<p>one</p> <p>two</p> <p>three</p>
';
$text = preg_replace('#<p>(?:(?!</p>).)*?three.*?</p>#i', '', $text);
echo $text;
index.php
, а параметры dispatch=discussion.view&thread_id=1
следует искать в %{QUERY_STRING} или %{THE_REQUEST}.RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} (?:^|&)dispatch=discussion\.view(?:$|&)
RewriteCond %{QUERY_STRING} (?:^|&)thread_id=(\d+)(?:$|&)
RewriteRule ^index\.php$ /reviews/%1/? [R=301,L]
RewriteRule ^reviews/(\d+)/$ /index.php?dispatch=discussion.view&thread_id=$1 [L]
u
, так что \w
совпадало только с латиницей.u
и [\w\s()\/.]+
стал захватывать текст на русском.u
, а \w
заменить на [a-zA-Z]
.$nomenclature = "4590 Ламінат Fiori Aqua Zero Дуб Iris фаска (1,67 м2)/5 шт";
preg_match("/^(К?[0-9\s]+).*?Ламінат\s([a-zA-Z\s()\/.]+|Х Galaxy 4V)\s([\p{L}\s.']+)/u", $nomenclature, $out);
var_dump($out);
PJSIP/(\d+)\S+ Up ([\d:]+).+?<(\d+)>
$str = '
Channel: Exten: CLCID: ========================================================================================== Channel: PJSIP/739-00009cf3/Dial Up 00:01:15 Exten: s CLCID: "CID:9622088888" <79379853222>
Channel: PJSIP/814-00009cf5/Dial Up 00:00:25 Exten: s CLCID: "CID:9622088888" <89119120799>
Channel: PJSIP/BEELINE_9622088888-00009cf4/AppDial Up 00:01:13 Exten: CLCID: "" <9622088888>
Channel: PJSIP/BEELINE_9622088888-00009cf6/AppDial Up 00:00:25 Exten: CLCID: "" <9622088888>
Objects found: 4
';
preg_match_all('~PJSIP/(\d+)\S+ Up ([\d:]+).+?<\K\d+~s', $str, $m, PREG_SET_ORDER);
print_r($m);
location /sandbox/hello/ {
try_files $uri $uri/ /sandbox/hello/index.php$is_args$args;
}
server {
listen 80;
listen [::]:80;
root /var/www/example_com;
index index.html index.php;
server_name example.com;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location /sandbox/hello/ {
try_files $uri $uri/ /sandbox/hello/index.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
rewrite ^/test$ /test.php;
location / {
try_files $uri @php;
}
location @php {
try_files $uri.php =404;
fastcgi_pass ... ;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
$text = 'клиент: краеугольный менеджер: желтый цвет';
$pattern = '/(клиент|менеджер):\h*(.*?)\h*(?=$|клиент:|менеджер:)/';
preg_match_all($pattern, $text, $matches);
$result = array_combine($matches[1], $matches[2]);
var_dump($result);
RewriteCond %{HTTP_HOST} ^subdomain2\.main-site\.ru$ [NC]
RewriteRule ^$ http://subdomain.main-site.ru/some-url [R=301,L]
RewriteCond %{HTTP_HOST} ^subdomain2\.main-site\.ru$ [NC]
RewriteRule ^$ http://subdomain.main-site.ru/some-url [P]
$text = preg_replace(
'#<a\b.*?</a>(*SKIP)(*F)|ipsum dolor#s',
'<a href="/article/2020">$0</a>',
$text
);
RewriteCond %{HTTP_HOST} ^cityname\.domain\.com$ [NC]
RewriteRule ^news/category/(\d+)$ /news/category-new/$1 [R=301,L]