运行 ❯
获取您自己的
PHP
服务器
×
更改方向
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>Regex Modifier: World$</h1> <p>Does the text "Hello World", end with "World"?:</p> <?php $txt = "Hello World"; $pattern = "/World$/"; echo preg_match_all($pattern, $txt); ?> <p>This method returns 1 if there is a match, otherwise 0.</p> <p>The matches were found here:</p> <?php echo preg_replace($pattern, "#", $txt); ?> <p>(The match was replaced by a # character)</p> </body> </html>
正则表达式修饰符:World$
文本“Hello World”是否以“World”结尾?
1
此方法如果匹配则返回 1,否则返回 0。
匹配结果在这里找到
Hello #
(匹配结果被 # 字符替换了)