Posted by Dan on Fri 27 Jun 22:12
report abuse | download | new post
- # Construct a regex fragment for handling normal tags. These can
- # be either a start or an end tag.
- h1 h2 h3 ul ol li
- b i strong em
- s sub super strike
- p pre code blockquote
- };;
- # Define a regex to match standard, open or close tags
- < # Open tag
- /? # Optional leading slash
- (?:$standard_tags_fragment) # Regex fragment to match tagnames
- > # Close tag
- }xms;
- # Construct a regex fragment for handling single, self-closing tags
- < # Open tag
- (?:$single_tags_fragment) # Regex fragment to match single tags
- \s*/? # Optional self-closing slash, with optional space
- > # Close tag
- };
- # Construct the final whitespace regexp
- $single_tags_re # Match an open or close tag
- | $standard_tags_re # Match a self-closing single tag
- # Special cases
- | <a[^>]+> # Match 'a' tags regardless of attributes
- | <img[^>]+> # Match 'img' regardless of attributes
- | </a> # Special case to catch close 'a' tags
- }xms;
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.