运行 ❯
获取你的
自有 PHP
服务器
×
更改方向
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>Regex Modifier: \S</h1> <p>How many non-whitespace characters are in the text "W3Schools has been live since 1999"?:</p> <?php $txt = "W3Schools has been live since 1999"; $pattern = "/\S/"; 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>
正则表达式修饰符:\S
文本 "W3Schools has been live since 1999" 中有多少个非空白字符?
29
匹配结果在这里
######### ### #### #### ##### ####
(每个匹配项都被替换为 # 字符)