Add a s?
if a space can be allowed.
s stands for white space
? says the preceding character may occur once or not occur.
If more than one spaces are allowed and is optional, use s*
.
* says preceding character can occur zero or more times.
'#<a hrefs?="(.*?)" titles?="(.*?)"><img alts?="(.*?)" srcs?="(.*?)"[s*]widths?="150"[s*]heights?="(.*?)"></a>#'
allows an optional space between attribute name and =.
If you want an optional space after the =
also, add a s?
after it also.
Likewise, wherever you have optional characters, you can use ?
if the maximum occurrence is 1 or *
if the maximum occurrence is unlimited, following the optional character.
And your actual problem was [s*]
which causes occurrence of a whitespace or a * as characters enclosed in [
and ]
is a character class. A character class allows occurrence of any of its members once (so remove *
from it) and if you append a quantifier (?
, +
, *
etc) after the ]
any character(s) in the character class can occur according to the quantifier.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…