執行 ❯
獲取您
自己的 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>
Regex Modifier: World$
文字“Hello World”是否以“World”結尾?
1
如果匹配成功,此方法返回 1,否則返回 0。
匹配項在此處找到
Hello #
(匹配項已替換為“#”字元)