Last active
November 10, 2021 16:57
-
-
Save erkobridee/a84579aa2a93c098860a095dfe385369 to your computer and use it in GitHub Desktop.
example of how to write a multiline RegExp and keep under row max length lint rules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const DEVICES_REGEXP = new RegExp([ | |
/Android|webOS/, | |
/|iPhone|iPad|iPod/, | |
/|BB10|BlackBerry/, | |
/|IEMobile|Opera Mini/, | |
/|Mobile|mobile/ | |
].map(function(r) {return r.source}).join(''), 'i'); | |
// output: /Android|webOS|iPhone|iPad|iPod|BB10|BlackBerry|IEMobile|Opera Mini|Mobile|mobile/i | |
/* | |
const buildRegExp = (regexps: RegExp[]) => | |
new RegExp(regexps.map((r) => r.source).join('')); | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment