我使用 RegexBuddy 来获得这个输出:
Match the characters “src=” literally «src=»
Match the regular expression below «(?:(['""])(?<src>(?:(?!\1).)*)\1|(?<src>[^\s>]+))»
Match either the regular expression below (attempting the next alternative only if this one fails) «(['""])(?<src>(?:(?!\1).)*)\1»
Match the regular expression below and capture its match into backreference number 1 «(['""])»
Match a single character present in the list “'"” «['""]»
Match the regular expression below and capture its match into backreference with name “src” «(?<src>(?:(?!\1).)*)»
Match the regular expression below «(?:(?!\1).)*»
Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
Assert that it is impossible to match the regex below starting at this position (negative lookahead) «(?!\1)»
Match the same text as most recently matched by capturing group number 1 «\1»
Match any single character that is not a line break character «.»
Match the same text as most recently matched by capturing group number 1 «\1»
Or match regular expression number 2 below (the entire group fails if this one fails to match) «(?<src>[^\s>]+)»
Match the regular expression below and capture its match into backreference with name “src” «(?<src>[^\s>]+)»
Match a single character NOT present in the list below «[^\s>]+»
Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
A whitespace character (spaces, tabs, line breaks, etc.) «\s»
The character “>” «>»
对于您所描述的内容,这个正则表达式非常糟糕。src="
是一个有效的输入。