Regular expression to get an attribute from HTML tag

前端 未结 4 1712
难免孤独
难免孤独 2020-12-03 03:55

I am looking for a regular expression that can get me src (case insensitive) tag from following HTML snippets in java.



        
4条回答
  •  旧时难觅i
    2020-12-03 04:25

    You mean the src-attribute of the img-Tag? In that case you can go with the following:

    <[Ii][Mm][Gg]\\s*([Ss][Rr][Cc]\\s*=\\s*[\"'].*?[\"'])
    

    That should work. The expression src='...' is in parantheses, so it is a matcher-group and can be processed separately.

提交回复
热议问题