Monthly Archives: August 2010

REGEX – Find unclosed img tags

As you probably know, the xhtml standard requires all tags to be properly closed.

This regular expression will search for unclosed img tags. It could be easily modified to grab any other unclosed html tags.
view source


<img([^>]+)(\s*[^\/])>

REGEX – Validate an URL

Is a particular url valid?  The following regexp will let you know.

/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \?=.-]*)*\/?$/

REGEX – Find all CSS attributes

This regexp will find CSS attributes, such as background:red; or padding-left:25px;.


\s(?[a-zA-Z-]+)\s[:]{1}\s*(?[a-zA-Z0-9\s.#]+)[;]{1}