Mailspring/src/regexp-utils.coffee

16 lines
563 B
CoffeeScript
Raw Normal View History

RegExpUtils =
# It's important that the regex be wrapped in parens, otherwise
# javascript's RegExp::exec method won't find anything even when the
# regex matches!
#
# It's also imporant we return a fresh copy of the RegExp every time. A
# javascript regex is stateful and multiple functions using this method
# will cause unexpected behavior!
emailRegex: -> new RegExp(/([a-z.A-Z0-9%+_-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4})/g)
# https://regex101.com/r/zG7aW4/3
imageTagRegex: -> /<img\s+[^>]*src="([^"]*)"[^>]*>/g
module.exports = RegExpUtils