python Regular Expressions Match Strings that Do Not Contain Certain Characters
- 2021-07-26 08:14:05
- OfStack
STEP 1 Match your target
All files in https? String beginning with://ending with. jpg. png. jpeg
2. Try the process
1)
Naturally think of the regular expression r '(https? ://.*? . jpghttps? ://.*? . pnghttps? ://.*? . jpeg) is simplified to r '(https? ://.*? \. (? : jpgpngjpeg)
Matching results: ['http://sdsdsdadadsdsdsddsdsdawwii, https://sdsdoijcjz. jpg'] found that the results were not what we wanted. After careful examination, symbols such as, or "appeared in the results, so these characters need to be removed
2) The expression is changed to r '(https?://[^ ",] *?\. jpghttps?://[^",] *?\. r' (https?://[^, "] *?\. (?: jpgpngjpeg))
Matching result: [https://sdsdoijcjz. jpg ']
Perfect match.