/images/img2.jpg" alt="" class="img"
As shown in the above code, there are two "img" words. I want to match the "img" in the first "img2", but does not include "2". I don't know how to achieve it.
If /img[0-9]/ is used, "2" is also included. Is there any way to match numbers followed by numbers, but the result does not include numbers?
/(img)d/.exec('/images/img2.jpg" alt="" class="img"')[1]
.match img and have numbers after it, the specific number of numbers depends on your match, and finally take it out The data in the matching group is img, grouped by parentheses
Thanks for the comment. It turns out that this is a suitable situation for using zero-width assertions. I looked up the information and wrote one.
The plus sign is preceded by the result to be matched ("img"), followed by the selection condition (meaning that img must contain a number), this solves the problem~
O(∩_∩)O~~