result = re.sub(
r"""(?x) # verbose regex
\b # Start of word
(?= # Look ahead to ensure that this word contains...
\w* # (after any number of alphanumeric characters)
\d # ...at least one digit.
) # End of lookahead
\w+ # Match the alphanumeric word
\s* # Match any following whitespace""",
"", subject)
您可以尝试用以下模式替换preg_:
像
$esc_string = preg_replace('/(\w*\d+\w*)/', '', $old_string);
我想这取决于“单词”是什么,但是如果我们把空格当作分隔符,如果它不一定是正则表达式:
是的,您可以:
相关问题 更多 >
编程相关推荐