Regular Expression to extract src attribute from img tag

后端 未结 7 1523
刺人心
刺人心 2020-12-14 19:46

I am trying to write a pattern for extracting the path for files found in img tags in HTML.

String string = \"

        
7条回答
  •  鱼传尺愫
    2020-12-14 20:36

    Your pattern should be (unescaped):

    src\s*=\s*"(.+?)"
    

    The important part is the added question mark that matches the group as few times as possible

提交回复
热议问题