我是正则表达式的新手,谁能帮我说出这几行话:
$body = preg_replace('/'s{6,}/ms','',$body);
提前谢谢。
$body = preg_replace('/'s{6,}/ms','',$body);
将空格 ( 's
) 替换为 6 到 6 到未定义的时间 ({6,}
),而没有。执行此多行操作。(/m
)。可以删除s
,当您不使用"所有字符"字符(.
)时,它不会增加任何值。
它删除至少 6 个连续空格字符的出现。
''s - 空格
定义为(水平)制表符、空格、换行符、回车符或表单换行符。
顺便说一句,模式修饰符是无用的:
-
m
会改变^
的行为,$
-
s
也使.
匹配换行符;否则它将在行尾停止。
基本上它的说法是连续用六个空格替换任何东西。
's = space
{6,} = between 6 and (since the second number after the comman is blank) 6
'ms = Used together, as /ms, they let the "." match any character whatsoever, while still allowing "^" and "$" to match, respectively, just after and just before newlines within the string.
另外,看看perldoc的perldoc,perl正则表达式将来可能会有所帮助。