运行 ❯
获取您
自己的 PHP
服务器
×
更改方向
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>Regex Modifier: \W</h1> <p>How many non-alphatbetical and non-digit characters are in the text "W3Schools.com"?:</p> <?php $txt = "W3Schools.com"; $pattern = "/\W/"; 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>
正则修饰符:\W
文本“W3Schools.com”中有多少个非字母和非数字字符?
1
匹配项在此处找到
W3Schools#com
(每次匹配都替换为“#”字符)