var FONTFACE_PATTERN = /(?:^|)(?:(?<=(?:font-family[:] ?))['"](.+?)['"]|(?<=(?:font-weight[:])) ?(.+?)|(?<=(?:font-style[:])) ?(.+?)|(?<=src: ?url[(])(?:['"]?data:(.+?)[;,](base64)[,])(.+?)(?:['"]?[)])(?:[\n\s ]?format[(]['"](\S+)['"][)])?)(?:[;][\n])(?:|$)/mdg
Rudimentary pattern for matching base64-embedded webfonts in CSS stylesheets, including:
font-familyfont-stylefont-weightAlso matches the various parts of the datauri sequence:
mime-typecharsetformat(...)Includes the multi-line and global modifier flags to match multiple @font-face rules in a single document.
MIT © Nicholas Berlette