Here is a Regular Expression to get the source value of an image
tag regardless of the location of the src
attribute.
(?<=img\s+[^>]*src\=[\x27\x22])[^\x27\x22]*(?=[\x27\x22])
Options: case insensitive
- Assert that the regex below can be matched, with the match ending at this position (positive lookbehind)
«(?<=img\s+[^>]*src\=[\x27\x22])»
- Match the characters “
img
” literally «img»
- Match a single character that is a “whitespace character” (spaces, tabs, line breaks, etc.)
«\s+»
- Between one and unlimited times, as many times as possible, giving back as needed (greedy)
«+»
- Match any character that is NOT a “
>
” «[^>]*»
- Between zero and unlimited times, as many times as possible, giving back as needed (greedy)
«*»
- Match the characters “
src
” literally «src»
- Match the character “
=
” literally «\=»
- Match a single character present in the list below
«[\x27\x22]»
- ASCII character 0×27 (39 decimal)
«\x27»
- ASCII character 0×22 (34 decimal)
«\x22»
- Match a single character NOT present in the list below
«[^\x27\x22]*»
- Between zero and unlimited times, as many times as possible, giving back as needed (greedy)
«*»
- ASCII character 0×27 (39 decimal)
«\x27»
- ASCII character 0×22 (34 decimal)
«\x22»
- Assert that the regex below can be matched, starting at this position (positive lookahead)
«(?=[\x27\x22])»
- Match a single character present in the list below
«[\x27\x22]»
- ASCII character 0×27 (39 decimal)
«\x27»
- ASCII character 0×22 (34 decimal)
«\x22»
Created with RegexBuddy