|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
I would like to know regular expression(s):
1. to find all the occurences of <img> tags (in HTML text) that are enclosed within <a> tags like <a><img /></a> 2. to find all the occurences of <img> tags (in HTML text) that are not enclosed within <a> tags |
|
#2
|
||||
|
||||
|
This would depend on which scripting language you are using. However, many of them use PCRE, including PHP, so I will show you how I would do it in PHP.
1) Code:
"/<a[^>]*>.*(<img[^>]*>)<\/a>/isU" 2) Code:
"/<[^a][a-z]+[^>]*>.*(<img[^>]*>)<\/[^a][a-z]+>/isU"
__________________
Spreading knowledge, one newbie at a time. Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions IE7: the generation 7 browser new in a world of generation 8 browsers. Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Other Programming Languages > Related to regular expression |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|