Regular Expression to extract src attribute from img tag

后端 未结 7 1510
刺人心
刺人心 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:28

    I'd like to expand on this topic as usually the src attribute comes unquoted so the regex to take the quoted and unquoted src attribute is:
    src\s*=\s*"?(.+?)["|\s]

提交回复
热议问题