Regular Expressions 101

Community Patterns

Superscript symbols and numbers in HTML only where valid.

0

Regular Expression
ECMAScript (JavaScript)

/
([a-zA--ÿ]+|^)(?<!(alt='|".+|href='|"|".+|<|>| \d\w| \w\d|\/\*))([1-9]|MC\/[1-9]|MD\/[1-9]|MC|MD|&yen;|&dagger;|&Dagger;|&loz;|&#x2662;|&diam;|&#8734;|&#450;|&#x1c2;|&infin;|&diams;|&reg;|&#x24c7;|&Delta;|&#916;|¥|||||||®||®\/||ǂ|§|Δ)(?=\s|\.|:|;||,|<|$)(?!\w| \d|\$|¢|&cent;|(&nbsp;))
/
g

Description

Superscript most symbols and numbers in HTML, but not in actual HTML tags where they also may appear but would create invalid HTML.

Submitted by Colin Whelan - a year ago