has characters
xxxx<img src=“a.jpg”>xxxx<img src=“b.jpg”>.......
If there are many words like this add img
tag
How to use regular expressions to change all img
tags into
xxxx<img src=“a.jpg” data-url="a.jpg">xxxx<img src=“b.jpg” data-url="b.jpg">.......
has one more data-url
, and its value is equal to src
has characters
xxxx<img src=“a.jpg”>xxxx<img src=“b.jpg”>.......
If there are many words like this add img
tag
How to use regular expressions to change all img
tags into
xxxx<img src=“a.jpg” data-url="a.jpg">xxxx<img src=“b.jpg” data-url="b.jpg">.......
has one more data-url
, and its value is equal to src
If it is the same attribute value, then can you just get the src attribute directly when getting it? I don’t understand what your needs are
But if you must use PHP regular implementation, you can also use the preg_replace_callback method to replace it. Use regular rules to match src="a.jpg" and replace it with src="a.jpg" data-url=" a.jpg" will do
Can I use jq? The following is the jq method
1 2 3 4 5 6 7 8 9 10 11 |
|