运行 ❯
获取您自己的
PHP
服务器
×
更改方向
更改主题,深色/浅色
转到 Spaces
<!DOCTYPE html> <html> <body> <h1>Regex Modifier: \b</h1> <p>Does the text "Hello World" start with "Hel"?:</p> <?php $txt = "Hello World"; $pattern = "/\bHel/"; 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>
正则表达式修饰符:\b
文本 "Hello World" 是否以 "Hel" 开头?
1
匹配结果在此处找到
#lo World
(每个匹配项都被替换为 # 字符)