试试这个
$result = preg_replace('/([\d\s]|<[^<>]+>)/', '_', $subject);
解释
"
( # Match the regular expression below and capture its match into backreference number 1
# Match either the regular expression below (attempting the next alternative only if this one fails)
[\d\s] # Match a single character present in the list below
# A single digit 0..9
# A whitespace character (spaces, tabs, and line breaks)
| # Or match regular expression number 2 below (the entire group fails if this one fails to match)
< # Match the character “<” literally
[^<>] # Match a single character NOT present in the list “<>”
+ # Between one and unlimited times, as many times as possible, giving back as needed (greedy)
> # Match the character “>” literally
)
"