This is probably a rather simple question to solve, butI’m trying to use a Regex on a string and have it remove any src attributes that contain dimensions, like this:
src="/some/path/here_000x000.jpg"
so
<img src="/some/path/here_000x000.jpg"/>
would become
<img />
after processing.
From researching I found that
\d{1,5}x\d{1,5}
finds dimensions, and
src\s*=\s*"(.+?)"
will find a src attribute, but how can I combine these both and have some simple c# code whereby all matching patterns in a given string are removed (ie. replaced with ”)?
Many thanks
Technically, you shouldn’t limit the digits to five (even though there shouldn’t be a need for such).
This matches
src(1), any number of spaces (2),=(3), any number of spaces (2),"(4), any number of any characters (except") (non-greedily) (5), any positive number of digits (6),x(7), any positive number of digits (6), any number of any characters (except newline) (non-greedily) (8), and"(3).src\s*="[^"]*?\d+x.*?