运行 ❯
获取您的
自己的 PHP
服务器
×
更改方向
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>Regex Modifier: o{2,5}</h1> <p>How many occurences of at least 2 preceeding o's (oo), but not more than 5 preceeding o's (ooooo) are in the text "W3Schools is goood"?:</p> <?php $txt = "W3Schools is gooood"; $pattern = "/o{2,5}/"; echo preg_match_all($pattern, $txt); ?> <p>The matches were found here:</p> <?php echo preg_replace($pattern, "#", $txt); ?> <p>(Each match was replaced by a # character)</p> </body> </html>
正则表达式修饰符:o{2,5}
在文本“W3Schools is goood”中,至少有 2 个前导 o(oo),但最多有 5 个前导 o(ooooo)的 o 出现了多少次?
2
匹配项在此处找到
W3Sch#ls is g#d
(每个匹配项都被替换为 # 字符)