'#^([a-z]+\s[a-z]+|[а-яё]+\s[а-яё]+)$#ui'
'#^[a-z]+\s[a-z]+$|^[а-яё]+\s[а-яё]+$#ui'
'#^([a-z]+)\s(?1)$|^([а-яё]+)\s(?2)$#ui'
server {
...
root /home/site/public_html;
rewrite ^/(ru|en)?/?(faq|news|page|catalogue|basket|photos|search|users)(.*)$ /index.php?lang=$1&module=$2&mod_rewrite=$3;
rewrite ^/$ /index.php;
location / { }
location ~ \.php$ {
fastcgi_pass unix:/tmp/php-fpm7.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|woff|ogg|mpe?g|avi|zip|gz|rar)$ {
add_header Pragma public;
add_header Cache-Control "public";
access_log /home/site/cache.log;
expires 1d;
}
}
$str = 'колесо';
$letters = preg_split('//u', $str, -1, PREG_SPLIT_NO_EMPTY);
foreach ($letters as $i => &$letter) {
$letter .= '(?!\\g' . ($i + 1) . ')()';
}
$regex = '#^(?:'.implode('|', $letters).')++$#u';
echo $regex, PHP_EOL;
$words = array ('колесо','колосс','оселок');
var_dump(preg_grep($regex, $words));
'#<a [^>]*href="(https://google\.com/[^"]*).+?</a>#isu'
'#<a [^>]*href="([^"]+)"[^>]*>(?:(?!</a>).)*\bLink1\b#isu'
(?s).*?(page\.php\?id=\d+|\z)
$1\n
'~(<h3>(?:(?!</?h3).)*</h3>)((?:(?!my-class).)*?)(<p>.*?</p>)~is'
'~(<h3>.*?</h3>)((?:my-class(*SKIP)(*F)|.)*?)(<p>.*?</p>)~is'
'~(?>(<h3>.*?</h3>)((?:my-class()|.)*?)(<p>.*?</p>))(?!\3)~is'
Нужно, чтобы захватывал многострочно. Флаг m стоит.
^ $
, а их нет в данной регулярке.s
совпадение будет и с переводами строк. $html = preg_replace('~<img[^>]*src="([^"]+)"[^>]*>|<a\b.+?</a>(*SKIP)(*F)~is', '<a href="$1">$0</a>', $html);
(^|,)(?i:[а-яё]()|[^,])++(?!\2)
(?:(^|,)(?i:[а-яё]()|[^,])*+(?!\2))+,?